1 Star 0 Fork 0

mamh-mixed/owncloud-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
.drone.star 109.90 KB
一键复制 编辑 原始数据 按行查看 历史
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172
ATMOZ_SFTP = "atmoz/sftp"
INBUCKET_INBUCKET = "inbucket/inbucket"
MINIO_MC_RELEASE_2020_VERSION = "minio/mc:RELEASE.2020-12-10T01-26-17Z"
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier"
OC_CI_CEPH = "owncloudci/ceph:tag-build-master-jewel-ubuntu-16.04"
OC_CI_CORE_NODEJS = "owncloudci/core:nodejs14"
OC_CI_DRONE_SKIP_PIPELINE = "owncloudci/drone-skip-pipeline"
OC_CI_NODEJS = "owncloudci/nodejs:%s"
OC_CI_ORACLE_XE = "owncloudci/oracle-xe:latest"
OC_CI_PHP = "owncloudci/php:%s"
OC_CI_SAMBA = "owncloudci/samba:latest"
OC_CI_SCALITY_S3SERVER = "owncloudci/scality-s3server:latest"
OC_CI_WAIT_FOR = "owncloudci/wait-for:latest"
OC_LITMUS = "owncloudci/litmus:latest"
OC_SERVER = "owncloud/server"
OC_UBUNTU = "owncloud/ubuntu:20.04"
OSIXIA_OPENLDAP = "osixia/openldap"
PLUGINS_GIT_ACTION = "plugins/git-action:1"
PLUGINS_S3 = "plugins/s3"
PLUGINS_S3_CACHE = "plugins/s3-cache:1"
PLUGINS_SLACK = "plugins/slack:1"
POTTAVA_PROXY = "pottava/proxy"
SELENIUM_STANDALONE_CHROME_DEBUG = "selenium/standalone-chrome-debug:3.141.59-oxygen"
SELENIUM_STANDALONE_FIREFOX_DEBUG = "selenium/standalone-firefox-debug:3.8.1"
SONARSOURCE_SONAR_SCANNER_CLI = "sonarsource/sonar-scanner-cli:5"
TOOLHIPPIE_CALENS = "toolhippie/calens:latest"
WEBHIPPIE_REDIS = "webhippie/redis:latest"
DEFAULT_PHP_VERSION = "7.4"
DEFAULT_NODEJS_VERSION = "14"
# minio mc environment variables
MINIO_MC_ENV = {
"CACHE_BUCKET": {
"from_secret": "cache_s3_bucket",
},
"MC_HOST": {
"from_secret": "cache_s3_server",
},
"AWS_ACCESS_KEY_ID": {
"from_secret": "cache_s3_access_key",
},
"AWS_SECRET_ACCESS_KEY": {
"from_secret": "cache_s3_secret_key",
},
}
dir = {
"base": "/drone",
"server": "/drone/src",
"federated": "/drone/federated",
"tarballServer": "/drone/core",
"browserService": "/home/seluser/Downloads",
}
config = {
"rocketchat": {
"channel": "server",
"from_secret": "rocketchat_talk_webhook",
},
"branches": [
"master",
],
"dependencies": True,
"codestyle": True,
"phpstan": True,
"phan": True,
"javascript": True,
"litmus": True,
"dav": True,
"phpunit": {
"mostDatabases": {
"phpVersions": [
DEFAULT_PHP_VERSION,
],
# Gather coverage for all databases except Oracle
"coverage": True,
"databases": [
"sqlite",
"mariadb:10.2",
"mariadb:10.3",
"mariadb:10.4",
"mariadb:10.5",
"mariadb:10.6",
"mariadb:10.7",
"mariadb:10.8",
"mariadb:10.11",
"mysql:5.5",
"mysql:5.7",
"mysql:8.0",
"postgres:9.4",
"postgres:10.21",
],
},
"slowDatabases": {
"phpVersions": [
DEFAULT_PHP_VERSION,
],
# Oracle takes a long time to start and run
# So do not collect coverage for that
# This helps the SonarCloud analysis to be ready much more quickly
"coverage": False,
"databases": [
"oracle",
],
},
"ubuntu22": {
"phpVersions": [
"7.4-ubuntu22.04",
],
# These pipelines are run just to help avoid any obscure regression
# on Ubuntu 22.04. We do not need coverage for this.
"coverage": False,
"databases": [
"sqlite",
"mariadb:10.6",
],
},
"external-samba": {
"phpVersions": [
DEFAULT_PHP_VERSION,
],
"databases": [
"sqlite",
],
"externalTypes": [
"samba",
],
"coverage": True,
"extraCommandsBeforeTestRun": [
"ls -l /var/cache",
"mkdir /var/cache/samba",
"ls -l /var/cache",
"ls -l /var/cache/samba",
],
},
"external-windows": {
"phpVersions": [
DEFAULT_PHP_VERSION,
],
"databases": [
"sqlite",
],
"externalTypes": [
"windows",
],
"coverage": True,
"extraEnvironment": {
"SMB_WINDOWS_HOST": {
"from_secret": "SMB_WINDOWS_HOST",
},
"SMB_WINDOWS_USERNAME": {
"from_secret": "SMB_WINDOWS_USERNAME",
},
"SMB_WINDOWS_PWD": {
"from_secret": "SMB_WINDOWS_PWD",
},
"SMB_WINDOWS_DOMAIN": {
"from_secret": "SMB_WINDOWS_DOMAIN",
},
"SMB_WINDOWS_SHARE_NAME": {
"from_secret": "SMB_WINDOWS_SHARE_NAME",
},
},
"extraCommandsBeforeTestRun": [
"ls -l /var/cache",
"mkdir /var/cache/samba",
"ls -l /var/cache",
"ls -l /var/cache/samba",
],
},
"external-other": {
"phpVersions": [
DEFAULT_PHP_VERSION,
],
"databases": [
"sqlite",
],
"externalTypes": [
"webdav",
"sftp",
"scality",
"owncloud",
],
"coverage": True,
},
},
"acceptance": {
"api": {
"suites": [
"apiAuth",
"apiAuthOcs",
"apiAuthWebDav",
"apiCapabilities",
"apiComments",
"apiFavorites",
"apiMain",
"apiProvisioning-v1",
"apiProvisioning-v2",
"apiProvisioningGroups-v1",
"apiProvisioningGroups-v2",
"apiShareCreateSpecialToRoot1",
"apiShareCreateSpecialToShares1",
"apiShareCreateSpecialToRoot2",
"apiShareCreateSpecialToShares2",
"apiSharees",
"apiShareManagementToRoot",
"apiShareManagementToShares",
"apiShareManagementBasicToRoot",
"apiShareManagementBasicToShares",
"apiShareOperationsToRoot1",
"apiShareOperationsToRoot2",
"apiShareOperationsToShares1",
"apiShareOperationsToShares2",
"apiSharePublicLink1",
"apiSharePublicLink2",
"apiSharePublicLink3",
"apiShareReshareToRoot1",
"apiShareReshareToShares1",
"apiShareReshareToRoot2",
"apiShareReshareToShares2",
"apiShareReshareToRoot3",
"apiShareReshareToShares3",
"apiShareUpdateToRoot",
"apiShareUpdateToShares",
"apiTags",
"apiTranslation",
"apiTrashbin",
"apiTrashbinRestore",
"apiVersions",
"apiWebdavDelete",
"apiWebdavEtagPropagation1",
"apiWebdavEtagPropagation2",
"apiWebdavLocks",
"apiWebdavLocks2",
"apiWebdavLocks3",
"apiWebdavLocksUnlock",
"apiWebdavMove1",
"apiWebdavMove2",
"apiWebdavOperations",
"apiWebdavPreviews",
"apiWebdavProperties1",
"apiWebdavProperties2",
"apiWebdavUpload1",
"apiWebdavUpload2",
],
"filterTags": "~@local_storage&&~@files_external-app-required",
},
"apiFilesExternal": {
"suites": {
"apiFilesExternal": "apiFilesExt",
},
"filterTags": "@files_external-app-required",
"runAllSuites": True,
"numberOfParts": 1,
"extraApps": {
"files_external": "",
},
},
"apiNotifications": {
"suites": [
"apiSharingNotificationsToRoot",
"apiSharingNotificationsToShares",
],
"extraApps": {
"notifications": 'if [ -f "composer.json" ]; then composer install; fi',
},
},
"apiFederation": {
"suites": [
"apiFederationToRoot1",
"apiFederationToRoot2",
"apiFederationToShares1",
"apiFederationToShares2",
],
"federatedServerNeeded": True,
"federatedServerVersions": ["git", "latest", "10.9.1"],
},
"cli": {
"suites": [
"cliCreateLocalStorage",
"cliBackground",
"cliLocalStorage",
"cliMain",
"cliProvisioning",
"cliTrashbin",
],
"filterTags": "~@local_storage&&~@files_external-app-required",
"emailNeeded": True,
},
"cliFilesExternal": {
"suites": {
"cliFilesExternal": "cliFilesExt",
},
"filterTags": "@files_external-app-required",
"runAllSuites": True,
"numberOfParts": 2,
"extraApps": {
"files_external": "",
},
},
"cliManageApps": {
"suites": [
"cliManageApps",
],
"testingRemoteSystem": False,
},
"cliEncryption": {
"phpVersions": [
DEFAULT_PHP_VERSION,
"7.4-ubuntu22.04",
],
"suites": [
"cliEncryption",
],
"extraApps": {
"encryption": "composer install",
},
"testingRemoteSystem": False,
"extraSetup": [{
"name": "configure-encryption",
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"commands": [
"php occ maintenance:singleuser --on",
"php occ encryption:enable",
"php occ encryption:encrypt-all --yes",
"php occ encryption:status",
"php occ maintenance:singleuser --off",
],
}],
"extraCommandsBeforeTestRun": [
"mkdir data/owncloud-keys",
"chown -R www-data data/owncloud-keys",
"chmod -R 0770 data/owncloud-keys",
],
},
"cliDbConversion": {
"suites": [
"cliDbConversion",
],
"databases": [
"sqlite",
],
"dbServices": [
"sqlite",
"mysql:8.0",
"postgres:10.21",
],
},
"cliExternalStorage": {
"suites": [
"cliExternalStorage",
],
"federatedServerNeeded": True,
"federatedServerVersions": ["git", "latest", "10.9.1"],
"extraApps": {
"files_external": "",
},
},
"webUI": {
"suites": {
"webUIAddUsers": "",
"webUIAdminSettings": "",
"webUIComments": "",
"webUICreateDelete": "",
"webUIFavorites": "",
"webUIFiles": "",
"webUILogin": "",
"webUIManageQuota": "",
"webUIManageUsersGroups": "webUIManageUsersGrps",
"webUIMoveFilesFolders": "webUIMoveFilesFolder",
"webUIPersonalSettings": "webUIPersonalSetting",
"webUIRenameFiles": "",
"webUIRenameFolders": "",
"webUIRestrictSharing": "",
"webUISettingsMenu": "",
"webUISharingAcceptShares": "webUISharingAcceptSh",
"webUISharingAutocompletion1": "webUISharingAutocomp1",
"webUISharingAutocompletion2": "webUISharingAutocomp2",
"webUISharingInternalGroups1": "webUISharingIntGroup1",
"webUISharingInternalGroups2": "webUISharingIntGroup2",
"webUISharingInternalUsers1": "webUISharingIntUsers1",
"webUISharingInternalUsers2": "webUISharingIntUsers2",
"webUISharingPublic1": "",
"webUISharingPublic2": "",
"webUITags": "",
"webUITrashbin": "",
"webUIUpload": "",
"webUIWebdavLockProtection": "webUIWebdavLockProt",
"webUIWebdavLocks": "",
"webUIWithCLI": "",
},
"filterTags": "~@local_storage&&~@files_external-app-required",
"emailNeeded": True,
"useHttps": False,
"selUserNeeded": True,
},
"webUIFilesExternal": {
"suites": {
"webUIFilesExternal": "webUIFilesExt",
},
"filterTags": "@files_external-app-required",
"runAllSuites": True,
"numberOfParts": 1,
"extraApps": {
"files_external": "",
},
},
"webUINotifications": {
"suites": {
"webUISharingNotifications": "webUISharingNotify",
},
"emailNeeded": True,
"useHttps": False,
"extraApps": {
"notifications": "composer install",
},
},
"webUIFileActionsMenu": {
"suites": {
"webUIFileActionsMenu": "",
},
"useHttps": False,
"extraApps": {
"files_texteditor": "make vendor",
"richdocuments": "make vendor",
},
},
"webUIFederation": {
"suites": {
"webUISharingExternal1": "webUISharingExt1",
"webUISharingExternal2": "webUISharingExt2",
},
"federatedServerNeeded": True,
"federatedServerVersions": ["git", "latest", "10.9.1"],
},
"webUIFirefox": {
"suites": {
"webUIFirefoxSmoketest": "webUIFfSmoke",
},
"browsers": [
"firefox",
],
"emailNeeded": True,
"useHttps": False,
"filterTags": "@smokeTest&&~@notifications-app-required",
"runAllSuites": True,
"numberOfParts": 3,
},
"webUIProxy": {
"suites": {
"webUIProxySmoketest": "webUIProxySmoke",
},
"browsers": [
"chrome",
],
"emailNeeded": True,
"proxyNeeded": True,
"useHttps": False,
"filterTags": "@smokeTest&&~@notifications-app-required",
"runAllSuites": True,
"numberOfParts": 3,
},
"webUIMobileSize": {
"suites": {
"webUIMobileSize": "",
},
"browsers": [
"chrome",
],
"emailNeeded": True,
"useHttps": False,
"filterTags": "@mobileResolutionTest&&~@notifications-app-required",
"runAllSuites": True,
"numberOfParts": 3,
"extraEnvironment": {
"MOBILE_RESOLUTION": "375x812",
"OC_LANGUAGE": "en-EN",
},
},
"apiProxy": {
"suites": {
"apiProxySmoketest": "apiProxySmoke",
},
"proxyNeeded": True,
"useHttps": False,
"filterTags": "@smokeTest&&~@notifications-app-required&&~@local_storage&&~@files_external-app-required",
"runAllSuites": True,
"numberOfParts": 8,
},
"apiUbuntu22": {
"phpVersions": [
"7.4-ubuntu22.04",
],
"suites": {
"apiUbuntu22": "apiUbuntu22",
},
"useHttps": False,
"filterTags": "@smokeTest&&~@notifications-app-required&&~@local_storage&&~@files_external-app-required",
"runAllSuites": True,
"numberOfParts": 8,
},
"apiOnSqlite": {
"suites": {
"apiOnSqlite": "apiOnSqlite",
},
"databases": ["sqlite"],
"useHttps": False,
"filterTags": "@sqliteDB",
"runAllSuites": True,
},
},
}
def main(ctx):
initial = initialPipelines(ctx)
before = beforePipelines(ctx)
dependsOn(initial, before)
coverageTests = coveragePipelines(ctx)
if (coverageTests == False):
print("Errors detected in coveragePipelines. Review messages above.")
return []
dependsOn(before, coverageTests)
nonCoverageTests = nonCoveragePipelines(ctx)
if (nonCoverageTests == False):
print("Errors detected in nonCoveragePipelines. Review messages above.")
return []
dependsOn(before, nonCoverageTests)
stages = stagePipelines(ctx)
if (stages == False):
print("Errors detected in stagePipelines. Review messages above.")
return []
dependsOn(before, stages)
if (coverageTests == []):
afterCoverageTests = []
else:
afterCoverageTests = afterCoveragePipelines(ctx)
dependsOn(coverageTests, afterCoverageTests)
after = afterPipelines(ctx)
dependsOn(afterCoverageTests + nonCoverageTests + stages, after)
return initial + before + coverageTests + afterCoverageTests + nonCoverageTests + stages + after
def initialPipelines(ctx):
return dependencies(ctx) + checkStarlark() + checkGitCommit()
def beforePipelines(ctx):
return codestyle(ctx) + changelog(ctx) + phpstan(ctx) + phan(ctx)
def coveragePipelines(ctx):
# All unit test pipelines that have coverage or other test analysis reported
jsPipelines = javascript(ctx, True)
phpUnitPipelines = phpTests(ctx, "phpunit", True)
phpIntegrationPipelines = phpTests(ctx, "phpintegration", True)
if (jsPipelines == False) or (phpUnitPipelines == False) or (phpIntegrationPipelines == False):
return False
return jsPipelines + phpUnitPipelines + phpIntegrationPipelines
def nonCoveragePipelines(ctx):
# All unit test pipelines that do not have coverage or other test analysis reported
jsPipelines = javascript(ctx, False)
phpUnitPipelines = phpTests(ctx, "phpunit", False)
phpIntegrationPipelines = phpTests(ctx, "phpintegration", False)
if (jsPipelines == False) or (phpUnitPipelines == False) or (phpIntegrationPipelines == False):
return False
return jsPipelines + phpUnitPipelines + phpIntegrationPipelines
def stagePipelines(ctx):
# Pipelines that do not produce coverage or other test analysis reports
litmusPipelines = litmus()
davPipelines = dav()
acceptancePipelines = acceptance(ctx)
if (litmusPipelines == False) or (davPipelines == False) or (acceptancePipelines == False):
return False
return litmusPipelines + davPipelines + acceptancePipelines
def afterCoveragePipelines(ctx):
return [
sonarAnalysis(ctx),
]
def afterPipelines(ctx):
return [
notify(),
]
def dependencies(ctx):
pipelines = []
if "dependencies" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
}
if "defaults" in config:
if "dependencies" in config["defaults"]:
for item in config["defaults"]["dependencies"]:
default[item] = config["defaults"]["dependencies"][item]
dependenciesConfig = config["dependencies"]
if type(dependenciesConfig) == "bool":
if dependenciesConfig:
# the config has 'dependencies' true, so specify an empty dict that will get the defaults
dependenciesConfig = {}
else:
return pipelines
if len(dependenciesConfig) == 0:
# 'dependencies' is an empty dict, so specify a single section that will get the defaults
dependenciesConfig = {"doDefault": {}}
for category, matrix in dependenciesConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
name = "install-dependencies-php%s" % phpVersion
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": cacheRestore() +
cacheClearOnEventPush(phpVersion) +
composerInstall(phpVersion) +
vendorbinCodestyle(phpVersion) +
vendorbinCodesniffer(phpVersion) +
vendorbinPhan(phpVersion) +
vendorbinPhpstan(phpVersion) +
vendorbinBehat() +
yarnInstall() +
cacheRebuildOnEventPush() +
cacheFlushOnEventPush(),
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
pipelines.append(result)
return pipelines
def codestyle(ctx):
pipelines = []
if "codestyle" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
}
if "defaults" in config:
if "codestyle" in config["defaults"]:
for item in config["defaults"]["codestyle"]:
default[item] = config["defaults"]["codestyle"][item]
codestyleConfig = config["codestyle"]
if type(codestyleConfig) == "bool":
if codestyleConfig:
# the config has 'codestyle' true, so specify an empty dict that will get the defaults
codestyleConfig = {}
else:
return pipelines
if len(codestyleConfig) == 0:
# 'codestyle' is an empty dict, so specify a single section that will get the defaults
codestyleConfig = {"doDefault": {}}
for category, matrix in codestyleConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
name = "coding-standard-php%s" % phpVersion
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "lint") +
cacheRestore() +
composerInstall(phpVersion) +
vendorbinCodestyle(phpVersion) +
vendorbinCodesniffer(phpVersion) +
[
{
"name": "php-style",
"image": OC_CI_PHP % phpVersion,
"commands": [
"make test-php-style",
],
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
pipelines.append(result)
return pipelines
def changelog(ctx):
repo_slug = ctx.build.source_repo if ctx.build.source_repo else ctx.repo.slug
pipelines = []
result = {
"kind": "pipeline",
"type": "docker",
"name": "changelog",
"clone": {
"disable": True,
},
"steps": [
{
"name": "clone",
"image": PLUGINS_GIT_ACTION,
"settings": {
"actions": [
"clone",
],
"remote": "https://github.com/%s" % (repo_slug),
"branch": ctx.build.source if ctx.build.event == "pull_request" else "master",
"path": dir["server"],
"netrc_machine": "github.com",
"netrc_username": {
"from_secret": "github_username",
},
"netrc_password": {
"from_secret": "github_token",
},
},
},
{
"name": "generate",
"image": TOOLHIPPIE_CALENS,
"commands": [
"calens >| CHANGELOG.md",
],
},
{
"name": "diff",
"image": OC_CI_ALPINE,
"commands": [
"git diff",
],
},
{
"name": "output",
"image": TOOLHIPPIE_CALENS,
"commands": [
"cat CHANGELOG.md",
],
},
{
"name": "publish",
"image": PLUGINS_GIT_ACTION,
"settings": {
"actions": [
"commit",
"push",
],
"message": "Automated changelog update [skip ci]",
"branch": "master",
"author_email": "devops@owncloud.com",
"author_name": "ownClouders",
"netrc_machine": "github.com",
"netrc_username": {
"from_secret": "github_username",
},
"netrc_password": {
"from_secret": "github_token",
},
},
"when": {
"ref": {
"exclude": [
"refs/pull/**",
],
},
},
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/heads/master",
"refs/pull/**",
],
},
}
pipelines.append(result)
return pipelines
def phpstan(ctx):
pipelines = []
if "phpstan" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
"logLevel": "2",
}
if "defaults" in config:
if "phpstan" in config["defaults"]:
for item in config["defaults"]["phpstan"]:
default[item] = config["defaults"]["phpstan"][item]
phpstanConfig = config["phpstan"]
if type(phpstanConfig) == "bool":
if phpstanConfig:
# the config has 'phpstan' true, so specify an empty dict that will get the defaults
phpstanConfig = {}
else:
return pipelines
if len(phpstanConfig) == 0:
# 'phpstan' is an empty dict, so specify a single section that will get the defaults
phpstanConfig = {"doDefault": {}}
for category, matrix in phpstanConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
name = "phpstan-php%s" % phpVersion
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "lint") +
cacheRestore() +
composerInstall(phpVersion) +
vendorbinPhpstan(phpVersion) +
installServer(phpVersion, "sqlite", params["logLevel"]) +
enableAppsForPhpStan(phpVersion) +
[
{
"name": "php-phpstan",
"image": OC_CI_PHP % phpVersion,
"commands": [
"make test-php-phpstan",
],
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
pipelines.append(result)
return pipelines
def phan(ctx):
pipelines = []
if "phan" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
"logLevel": "2",
}
if "defaults" in config:
if "phan" in config["defaults"]:
for item in config["defaults"]["phan"]:
default[item] = config["defaults"]["phan"][item]
phanConfig = config["phan"]
if type(phanConfig) == "bool":
if phanConfig:
# the config has 'phan' true, so specify an empty dict that will get the defaults
phanConfig = {}
else:
return pipelines
if len(phanConfig) == 0:
# 'phan' is an empty dict, so specify a single section that will get the defaults
phanConfig = {"doDefault": {}}
for category, matrix in phanConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
name = "phan-php%s" % phpVersion
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "lint") + cacheRestore() +
composerInstall(phpVersion) +
vendorbinPhan(phpVersion) +
installServer(phpVersion, "sqlite", params["logLevel"]) +
[
{
"name": "phan",
"image": OC_CI_PHP % phpVersion,
"commands": [
"make test-php-phan",
],
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
pipelines.append(result)
return pipelines
def litmus():
pipelines = []
if "litmus" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
"logLevel": "2",
"useHttps": True,
}
if "defaults" in config:
if "litmus" in config["defaults"]:
for item in config["defaults"]["litmus"]:
default[item] = config["defaults"]["litmus"][item]
litmusConfig = config["litmus"]
if type(litmusConfig) == "bool":
if litmusConfig:
# the config has 'litmus' true, so specify an empty dict that will get the defaults
litmusConfig = {}
else:
return pipelines
if len(litmusConfig) == 0:
# 'litmus' is an empty dict, so specify a single section that will get the defaults
litmusConfig = {"doDefault": {}}
for category, matrix in litmusConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
name = "litmus-php%s" % phpVersion
db = "mariadb:10.2"
environment = {
"LITMUS_PASSWORD": "admin",
"LITMUS_USERNAME": "admin",
"TESTS": "basic copymove props locks http",
}
litmusCommand = "/usr/local/bin/litmus-wrapper"
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": cacheRestore() +
composerInstall(phpVersion) +
installServer(phpVersion, db, params["logLevel"], params["useHttps"]) +
setupLocalStorage(phpVersion) +
fixPermissions(phpVersion, False) +
createShare(phpVersion) +
owncloudLog("server", "src") +
[
{
"name": "old-endpoint",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/webdav"',
litmusCommand,
],
},
{
"name": "new-endpoint",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/dav/files/admin"',
litmusCommand,
],
},
{
"name": "new-mount",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/dav/files/admin/local_storage/"',
litmusCommand,
],
},
{
"name": "old-mount",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/webdav/local_storage/"',
litmusCommand,
],
},
{
"name": "new-shared",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/dav/files/admin/new_folder/"',
litmusCommand,
],
},
{
"name": "old-shared",
"image": OC_LITMUS,
"environment": environment,
"commands": [
"source .env",
'export LITMUS_URL="https://server/remote.php/webdav/new_folder/"',
litmusCommand,
],
},
{
"name": "pub-share-copymove",
"image": OC_LITMUS,
"environment": {
"LITMUS_PASSWORD": "admin",
"LITMUS_USERNAME": "admin",
"TESTS": "copymove",
},
"commands": [
"source .env",
"export LITMUS_URL='https://server/remote.php/dav/public-files/'$PUBLIC_TOKEN",
litmusCommand,
],
},
{
"name": "pub-share-http",
"image": OC_LITMUS,
"environment": {
"LITMUS_PASSWORD": "admin",
"LITMUS_USERNAME": "admin",
"TESTS": "http",
},
"commands": [
"source .env",
"export LITMUS_URL='https://server/remote.php/dav/public-files/'$PUBLIC_TOKEN",
litmusCommand,
],
},
{
"name": "pub-share-basic",
"image": OC_LITMUS,
"environment": {
"LITMUS_PASSWORD": "admin",
"LITMUS_USERNAME": "admin",
"TESTS": "basic",
},
"commands": [
"source .env",
"export LITMUS_URL='https://server/remote.php/dav/public-files/'$PUBLIC_TOKEN",
"%s/tests/litmus/run.sh" % dir["server"],
],
},
],
"services": databaseService(db) +
owncloudService(phpVersion, "server", dir["server"], params["useHttps"]),
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
pipelines.append(result)
return pipelines
def dav():
pipelines = []
if "dav" not in config:
return pipelines
default = {
"phpVersions": [DEFAULT_PHP_VERSION],
"logLevel": "2",
}
if "defaults" in config:
if "dav" in config["defaults"]:
for item in config["defaults"]["dav"]:
default[item] = config["defaults"]["dav"][item]
davConfig = config["dav"]
if type(davConfig) == "bool":
if davConfig:
# the config has 'dav' true, so specify an empty dict that will get the defaults
davConfig = {}
else:
return pipelines
if len(davConfig) == 0:
# 'dav' is an empty dict, so specify a single section that will get the defaults
davConfig = {"doDefault": {}}
for category, matrix in davConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
for phpVersion in params["phpVersions"]:
for davType in ["caldav-new", "caldav-old", "carddav-new", "carddav-old"]:
name = "%s-php%s" % (davType, phpVersion)
db = "mariadb:10.2"
if (davType == "caldav-new"):
scriptPath = "apps/dav/tests/ci/caldav"
if (davType == "caldav-old"):
scriptPath = "apps/dav/tests/ci/caldav-old-endpoint"
if (davType == "carddav-new"):
scriptPath = "apps/dav/tests/ci/carddav"
if (davType == "carddav-old"):
scriptPath = "apps/dav/tests/ci/carddav-old-endpoint"
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": cacheRestore() +
composerInstall(phpVersion) +
installServer(phpVersion, db, params["logLevel"]) +
davInstall(phpVersion, scriptPath) +
fixPermissions(phpVersion, False) +
[
{
"name": "dav-test",
"image": OC_CI_PHP % phpVersion,
"commands": [
"bash %s/script.sh" % scriptPath,
],
},
],
"services": databaseService(db),
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
pipelines.append(result)
return pipelines
def javascript(ctx, withCoverage):
pipelines = []
if "javascript" not in config:
return pipelines
default = {
"coverage": True,
"logLevel": "2",
"skip": False,
}
if "defaults" in config:
if "javascript" in config["defaults"]:
for item in config["defaults"]["javascript"]:
default[item] = config["defaults"]["javascript"][item]
matrix = config["javascript"]
if type(matrix) == "bool":
if matrix:
# the config has 'javascript' true, so specify an empty dict that will get the defaults
matrix = {}
else:
return pipelines
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
if params["skip"]:
return pipelines
# if we only want pipelines with coverage, and this pipeline does not do coverage, then do not include it
if withCoverage and not params["coverage"]:
return pipelines
# if we only want pipelines without coverage, and this pipeline does coverage, then do not include it
if not withCoverage and params["coverage"]:
return pipelines
result = {
"kind": "pipeline",
"type": "docker",
"name": "test-javascript",
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "unit-tests") + cacheRestore() +
yarnInstall() +
[
{
"name": "test-js",
"image": OC_CI_NODEJS % DEFAULT_NODEJS_VERSION,
"commands": [
"make test-js",
],
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
if params["coverage"]:
result["steps"].append(
{
"name": "coverage-cache",
"image": PLUGINS_S3,
"settings": {
"endpoint": {
"from_secret": "cache_s3_server",
},
"bucket": "cache",
"source": "tests/output/coverage/lcov.info",
"target": "%s/%s/coverage" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
"path_style": True,
"strip_prefix": "tests/output/coverage",
"access_key": {
"from_secret": "cache_s3_access_key",
},
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
},
)
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
return [result]
def phpTests(ctx, testType, withCoverage):
pipelines = []
if testType not in config:
return pipelines
errorFound = False
# The default PHP unit test settings for a PR.
# Note: do not run Oracle by default in PRs.
prDefault = {
"phpVersions": [DEFAULT_PHP_VERSION],
"databases": [
"sqlite",
"mariadb:10.2",
"mariadb:10.3",
"mariadb:10.4",
"mariadb:10.5",
"mariadb:10.6",
"mariadb:10.7",
"mariadb:10.8",
"mariadb:10.11",
"mysql:5.5",
"mysql:5.7",
"mysql:8.0",
"postgres:9.4",
"postgres:10.21",
],
"coverage": True,
"includeKeyInMatrixName": False,
"logLevel": "2",
"cephS3": False,
"scalityS3": False,
"externalTypes": ["none"],
"extraSetup": [],
"extraServices": [],
"extraEnvironment": {},
"extraCommandsBeforeTestRun": [],
"extraApps": {},
"skip": False,
}
# The default PHP unit test settings for the cron job (usually runs nightly).
cronDefault = {
"phpVersions": [DEFAULT_PHP_VERSION],
"databases": [
"sqlite",
"mariadb:10.2",
"mariadb:10.3",
"mariadb:10.4",
"mariadb:10.5",
"mariadb:10.6",
"mariadb:10.7",
"mariadb:10.8",
"mariadb:10.9",
"mariadb:10.10",
"mariadb:10.11",
"mysql:5.5",
"mysql:5.7",
"mysql:8.0",
"postgres:9.4",
"postgres:10.21",
"oracle",
],
"coverage": True,
"includeKeyInMatrixName": False,
"logLevel": "2",
"cephS3": False,
"scalityS3": False,
"externalTypes": ["none"],
"extraSetup": [],
"extraServices": [],
"extraEnvironment": {},
"extraCommandsBeforeTestRun": [],
"extraApps": {},
"skip": False,
}
if (ctx.build.event == "cron"):
default = cronDefault
else:
default = prDefault
if "defaults" in config:
if testType in config["defaults"]:
for item in config["defaults"][testType]:
default[item] = config["defaults"][testType][item]
phpTestConfig = config[testType]
if type(phpTestConfig) == "bool":
if phpTestConfig:
# the config has just True, so specify an empty dict that will get the defaults
phpTestConfig = {}
else:
return pipelines
if len(phpTestConfig) == 0:
# the PHP test config is an empty dict, so specify a single section that will get the defaults
phpTestConfig = {"doDefault": {}}
for category, matrix in phpTestConfig.items():
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
if params["skip"]:
continue
# if we only want pipelines with coverage, and this pipeline does not do coverage, then do not include it
if withCoverage and not params["coverage"]:
continue
# if we only want pipelines without coverage, and this pipeline does coverage, then do not include it
if not withCoverage and params["coverage"]:
continue
for phpVersion in params["phpVersions"]:
if testType == "phpunit":
command = "setpriv --reuid=www-data --regid=www-data --init-groups bash tests/drone/test-phpunit.sh"
else:
command = "unknown tbd"
# Shorten PHP docker tags that have longer names like 7.4-ubuntu22.04
phpVersionString = phpVersion.replace("-ubuntu", "-u")
for db in params["databases"]:
for externalType in params["externalTypes"]:
keyString = "-" + category if params["includeKeyInMatrixName"] else ""
filesExternalType = externalType if externalType != "none" else ""
externalNameString = "-" + externalType if externalType != "none" else ""
name = "%s%s-php%s-%s%s" % (testType, keyString, phpVersionString, getShortDbNameAndVersion(db), externalNameString)
maxLength = 50
nameLength = len(name)
if nameLength > maxLength:
print("Error: generated phpunit stage name of length", nameLength, "is not supported. The maximum length is " + str(maxLength) + ".", name)
errorFound = True
if ((externalType == "scality") or (params["scalityS3"] != False)):
needScality = True
filesExternalType = ""
primaryObjectStore = "files_primary_s3"
else:
needScality = False
primaryObjectStore = ""
if (filesExternalType == ""):
# for the regular unit test runs, the clover coverage results are in a file named like:
# autotest-clover-sqlite.xml
coverageFileNameStart = "autotest"
extraCoverageRenameCommand = []
extraCoverage = False
else:
# for the files-external unit test runs, the clover coverage results are in 2 files named like:
# autotest-external-clover-sqlite.xml
# autotest-external-clover-sqlite-samba.xml
coverageFileNameStart = "autotest-external"
extraCoverageRenameCommand = [
"mv tests/output/coverage/%s-clover-%s-%s.xml tests/output/coverage/clover-%s-%s.xml" % (coverageFileNameStart, getDbName(db), externalType, name, externalType),
]
extraCoverage = True
if ((externalType == "scality") or (params["cephS3"] != False) or (params["scalityS3"] != False)):
# If we need S3 storage, then install the 'files_primary_s3' app
extraAppsDict = {
"files_primary_s3": "composer install",
}
else:
extraAppsDict = {}
if (externalType == "owncloud"):
needRedis = True
else:
needRedis = False
for app, command in params["extraApps"].items():
extraAppsDict[app] = command
environment = {}
for env in params["extraEnvironment"]:
environment[env] = params["extraEnvironment"][env]
environment["COVERAGE"] = params["coverage"]
environment["DB_TYPE"] = getDbName(db)
environment["FILES_EXTERNAL_TYPE"] = filesExternalType
environment["PRIMARY_OBJECTSTORE"] = primaryObjectStore
environment["SCALITY"] = needScality
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "unit-tests") +
cacheRestore() +
composerInstall(phpVersion) +
installServer(phpVersion, db, params["logLevel"]) +
installExtraApps(phpVersion, extraAppsDict, dir["server"]) +
setupScality(phpVersion, needScality) +
params["extraSetup"] +
fixPermissions(phpVersion, False) +
[
{
"name": "%s-tests" % testType,
"image": OC_CI_PHP % phpVersion,
"environment": environment,
"commands": params["extraCommandsBeforeTestRun"] + [
command,
],
},
],
"services": databaseService(db) +
cephService(params["cephS3"]) +
scalityService(needScality) +
webdavService(externalType == "webdav") +
sambaService(externalType == "samba") +
sftpService(externalType == "sftp") +
redisService(needRedis) +
owncloudDockerService(externalType == "owncloud") +
params["extraServices"],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
}
if params["coverage"] and not needScality:
result["steps"].append({
"name": "coverage-rename",
"image": OC_CI_PHP % phpVersion,
"commands": [
"mv tests/output/coverage/%s-clover-%s.xml tests/output/coverage/clover-%s.xml" % (coverageFileNameStart, getDbName(db), name),
] + extraCoverageRenameCommand,
})
result["steps"].append({
"name": "coverage-cache-1",
"image": PLUGINS_S3,
"settings": {
"endpoint": {
"from_secret": "cache_s3_server",
},
"bucket": "cache",
"source": "tests/output/coverage/clover-%s.xml" % (name),
"target": "%s/%s/coverage" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
"path_style": True,
"strip_prefix": "tests/output/coverage",
"access_key": {
"from_secret": "cache_s3_access_key",
},
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
})
if extraCoverage:
result["steps"].append({
"name": "coverage-cache-2",
"image": PLUGINS_S3,
"settings": {
"endpoint": {
"from_secret": "cache_s3_server",
},
"bucket": "cache",
"source": "tests/output/coverage/clover-%s-%s.xml" % (name, externalType),
"target": "%s/%s/coverage" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
"path_style": True,
"strip_prefix": "tests/output/coverage",
"access_key": {
"from_secret": "cache_s3_access_key",
},
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
})
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
pipelines.append(result)
if errorFound:
return False
return pipelines
def acceptance(ctx):
pipelines = []
if "acceptance" not in config:
return pipelines
if type(config["acceptance"]) == "bool":
if not config["acceptance"]:
return pipelines
errorFound = False
default = {
"federatedServerVersions": [""],
"browsers": ["chrome"],
"phpVersions": [DEFAULT_PHP_VERSION],
"databases": ["mariadb:10.2"],
"federatedPhpVersion": DEFAULT_PHP_VERSION,
"federatedServerNeeded": False,
"federatedDb": "",
"filterTags": "",
"logLevel": "2",
"emailNeeded": False,
"ldapNeeded": False,
"proxyNeeded": False,
"cephS3": False,
"scalityS3": False,
"testingRemoteSystem": True,
"useHttps": True,
"replaceUsernames": False,
"extraSetup": [],
"extraServices": [],
"extraEnvironment": {"OC_LANGUAGE": "en-EN"},
"extraCommandsBeforeTestRun": [],
"extraApps": {},
"useBundledApp": False,
"includeKeyInMatrixName": False,
"runAllSuites": False,
"numberOfParts": 1,
"skip": False,
"debugSuites": [],
"skipExceptParts": [],
"testAgainstCoreTarball": False,
"coreTarball": "daily-master-qa",
"selUserNeeded": False,
"dbServices": [],
}
if "defaults" in config:
if "acceptance" in config["defaults"]:
for item in config["defaults"]["acceptance"]:
default[item] = config["defaults"]["acceptance"][item]
for category, matrix in config["acceptance"].items():
if type(matrix["suites"]) == "list":
suites = {}
for suite in matrix["suites"]:
suites[suite] = suite
else:
suites = matrix["suites"]
if "debugSuites" in matrix and len(matrix["debugSuites"]) != 0:
if type(matrix["debugSuites"]) == "list":
suites = {}
for suite in matrix["debugSuites"]:
suites[suite] = suite
else:
suites = matrix["debugSuites"]
for suite, alternateSuiteName in suites.items():
isWebUI = suite.startswith("webUI")
isAPI = suite.startswith("api")
isCLI = suite.startswith("cli")
if (alternateSuiteName == ""):
alternateSuiteName = suite
params = {}
for item in default:
params[item] = matrix[item] if item in matrix else default[item]
if params["skip"]:
continue
if isAPI or isCLI:
params["browsers"] = [""]
needObjectStore = (params["cephS3"] != False) or (params["scalityS3"] != False)
extraAppsDict = {}
if not params["testAgainstCoreTarball"]:
extraAppsDict["testing"] = "composer install"
if (needObjectStore):
# If we need S3 object storage, then install the 'files_primary_s3' app
extraAppsDict["files_primary_s3"] = "composer install"
for app, command in params["extraApps"].items():
extraAppsDict[app] = command
for federatedServerVersion in params["federatedServerVersions"]:
for browser in params["browsers"]:
for phpVersion in params["phpVersions"]:
# Shorten PHP docker tags that have longer names like 7.4-ubuntu22.04
phpVersionString = phpVersion.replace("-ubuntu", "-u")
for db in params["databases"]:
for runPart in range(1, params["numberOfParts"] + 1):
debugPartsEnabled = (len(params["skipExceptParts"]) != 0)
if debugPartsEnabled and runPart not in params["skipExceptParts"]:
continue
name = "unknown"
federatedDb = db if params["federatedDb"] == "" else params["federatedDb"]
federatedDbName = getDbName(federatedDb)
if federatedDbName not in ["mariadb", "mysql"]:
# Do not try to run 2 sets of Oracle, Postgres etc databases
# When testing with these, let the federated server use mariadb
federatedDb = "mariadb:10.2"
if isWebUI or isAPI or isCLI:
browserString = "" if browser == "" else "-" + browser
keyString = "-" + category if params["includeKeyInMatrixName"] else ""
partString = "" if params["numberOfParts"] == 1 else "-%d-%d" % (params["numberOfParts"], runPart)
federatedServerVersionString = "-" + federatedServerVersion.replace("daily-", "").replace("-qa", "") if (federatedServerVersion != "") else ""
name = "%s%s%s%s%s-%s-php%s" % (alternateSuiteName, keyString, partString, federatedServerVersionString, browserString, getShortDbNameAndVersion(db), phpVersionString)
maxLength = 50
nameLength = len(name)
if nameLength > maxLength:
print("Error: generated stage name of length", nameLength, "is not supported. The maximum length is " + str(maxLength) + ".", name)
errorFound = True
environment = {}
for env in params["extraEnvironment"]:
environment[env] = params["extraEnvironment"][env]
if (params["useHttps"]):
protocol = "https"
else:
protocol = "http"
if (params["proxyNeeded"]):
serverUnderTest = "proxy"
else:
serverUnderTest = "server"
environment["TEST_SERVER_URL"] = "%s://%s" % (protocol, serverUnderTest)
environment["BEHAT_FILTER_TAGS"] = params["filterTags"]
environment["REPLACE_USERNAMES"] = params["replaceUsernames"]
environment["DOWNLOADS_DIRECTORY"] = "%s/downloads" % dir["server"]
if (params["runAllSuites"] == False):
environment["BEHAT_SUITE"] = suite
else:
environment["DIVIDE_INTO_NUM_PARTS"] = params["numberOfParts"]
environment["RUN_PART"] = runPart
if isWebUI:
environment["SELENIUM_HOST"] = "selenium"
environment["SELENIUM_PORT"] = "4444"
environment["BROWSER"] = browser
environment["PLATFORM"] = "Linux"
makeParameter = "test-acceptance-webui"
if isAPI:
makeParameter = "test-acceptance-api"
if isCLI:
makeParameter = "test-acceptance-cli"
if params["emailNeeded"]:
environment["EMAIL_HOST"] = "email"
if params["ldapNeeded"]:
environment["TEST_WITH_LDAP"] = True
if params["testingRemoteSystem"]:
environment["TESTING_REMOTE_SYSTEM"] = True
suExecCommand = ""
else:
environment["TESTING_REMOTE_SYSTEM"] = False
# The test suite (may/will) run local commands, rather than calling the testing app to do them
# Those commands need to be executed as www-data (which owns the files)
suExecCommand = "setpriv --reuid=www-data --regid=www-data --init-groups "
if params["testAgainstCoreTarball"]:
pathOfServerUnderTest = dir["tarballServer"]
else:
pathOfServerUnderTest = dir["server"]
if (needObjectStore):
environment["OC_TEST_ON_OBJECTSTORE"] = "1"
if (params["cephS3"] != False):
environment["S3_TYPE"] = "ceph"
if (params["scalityS3"] != False):
environment["S3_TYPE"] = "scality"
federationDbSuffix = "fed"
# database services
dbServices = databaseService(db)
for dbService in params["dbServices"]:
if (dbService != db):
dbServices += databaseService(dbService)
result = {
"kind": "pipeline",
"type": "docker",
"name": name,
"workspace": {
"base": dir["base"],
"path": "src",
},
"steps": skipIfUnchanged(ctx, "acceptance-tests") +
cacheRestore() +
composerInstall(phpVersion) +
vendorbinBehat() +
yarnInstall() +
((
installCoreFromTarball(params["coreTarball"], db, params["logLevel"], params["useHttps"], params["federatedServerNeeded"], params["proxyNeeded"], pathOfServerUnderTest)
) if params["testAgainstCoreTarball"] else (
installServer(phpVersion, db, params["logLevel"], params["useHttps"], params["federatedServerNeeded"], params["proxyNeeded"])
)) +
(
installAndConfigureFederated(ctx, federatedServerVersion, params["federatedPhpVersion"], params["logLevel"], protocol, federatedDb, federationDbSuffix) +
owncloudLog("federated", "federated") if params["federatedServerNeeded"] else []
) +
installExtraApps(phpVersion, extraAppsDict, pathOfServerUnderTest) +
setupCeph(phpVersion, params["cephS3"]) +
setupScality(phpVersion, params["scalityS3"]) +
params["extraSetup"] +
waitForServer(params["federatedServerNeeded"]) +
waitForEmailService(params["emailNeeded"]) +
waitForBrowserService(browser) +
fixPermissions(phpVersion, params["federatedServerNeeded"], params["selUserNeeded"], pathOfServerUnderTest) +
owncloudLog("server", pathOfServerUnderTest) +
[
({
"name": "acceptance-tests",
"image": OC_CI_PHP % phpVersion,
"environment": environment,
"commands": params["extraCommandsBeforeTestRun"] + [
"touch %s/saved-settings.sh" % dir["base"],
". %s/saved-settings.sh" % dir["base"],
"%smake %s" % (suExecCommand, makeParameter),
],
"volumes": [{
"name": "downloads",
"path": "%s/downloads" % dir["server"],
}],
}),
],
"services": dbServices +
browserService(browser) +
emailService(params["emailNeeded"]) +
ldapService(params["ldapNeeded"]) +
proxyService(params["proxyNeeded"]) +
cephService(params["cephS3"]) +
scalityService(params["scalityS3"]) +
params["extraServices"] +
owncloudService(phpVersion, "server", pathOfServerUnderTest, params["useHttps"]) +
((
owncloudService(params["federatedPhpVersion"], "federated", dir["federated"], params["useHttps"]) +
databaseServiceForFederation(federatedDb, federationDbSuffix)
) if params["federatedServerNeeded"] else []),
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
"refs/tags/**",
],
},
"volumes": [{
"name": "downloads",
"temp": {},
}],
}
pipelines.append(result)
if errorFound:
return False
return pipelines
def sonarAnalysis(ctx, phpVersion = DEFAULT_PHP_VERSION):
sonar_env = {
"SONAR_TOKEN": {
"from_secret": "sonar_token",
},
"SONAR_SCANNER_OPTS": "-Xdebug",
}
if ctx.build.event == "pull_request":
sonar_env.update({
"SONAR_PULL_REQUEST_BASE": "%s" % (ctx.build.target),
"SONAR_PULL_REQUEST_BRANCH": "%s" % (ctx.build.source),
"SONAR_PULL_REQUEST_KEY": "%s" % (ctx.build.ref.replace("refs/pull/", "").split("/")[0]),
})
repo_slug = ctx.build.source_repo if ctx.build.source_repo else ctx.repo.slug
result = {
"kind": "pipeline",
"type": "docker",
"name": "sonar-analysis",
"workspace": {
"base": dir["base"],
"path": "src",
},
"clone": {
"disable": True, # Sonarcloud does not apply issues on already merged branch
},
"steps": [
{
"name": "clone",
"image": OC_CI_ALPINE,
"commands": [
"git clone https://github.com/%s.git ." % (repo_slug),
"git checkout $DRONE_COMMIT",
],
},
] +
skipIfUnchanged(ctx, "unit-tests") +
cacheRestore() +
composerInstall(phpVersion) +
yarnInstall() +
installServer(phpVersion, "sqlite") +
[
{
"name": "sync-from-cache",
"image": MINIO_MC_RELEASE_2020_VERSION,
"environment": MINIO_MC_ENV,
"commands": [
"mkdir -p results",
"mc alias set cache $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY",
"mc mirror cache/$CACHE_BUCKET/%s/%s/coverage results/" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
],
},
{
"name": "setup-before-sonarcloud",
"image": OC_CI_PHP % phpVersion,
"commands": [
"pwd",
"ls -l",
"ls -l results",
"ls -l apps",
"ls -l config",
"cd apps",
"git clone https://github.com/owncloud/files_primary_s3.git",
"cd files_primary_s3",
"composer install",
"cd %s" % dir["server"],
],
},
{
"name": "sonarcloud",
"image": SONARSOURCE_SONAR_SCANNER_CLI,
"environment": sonar_env,
},
{
"name": "purge-cache",
"image": MINIO_MC_RELEASE_2020_VERSION,
"environment": MINIO_MC_ENV,
"commands": [
"mc alias set cache $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY",
"mc rm --recursive --force cache/$CACHE_BUCKET/%s/%s" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
],
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/heads/master",
"refs/pull/**",
"refs/tags/**",
],
},
}
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
return result
def notify():
result = {
"kind": "pipeline",
"type": "docker",
"name": "chat-notifications",
"clone": {
"disable": True,
},
"steps": [
{
"name": "notify-rocketchat",
"image": PLUGINS_SLACK,
"settings": {
"webhook": {
"from_secret": config["rocketchat"]["from_secret"],
},
"channel": config["rocketchat"]["channel"],
},
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/tags/**",
],
"status": [
"success",
"failure",
],
},
}
for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)
return result
def databaseService(db):
dbName = getDbName(db)
if (dbName == "mariadb") or (dbName == "mysql"):
service = {
"name": dbName,
"image": db,
"environment": {
"MYSQL_USER": getDbUsername(db),
"MYSQL_PASSWORD": getDbPassword(db),
"MYSQL_DATABASE": getDbDatabase(db),
"MYSQL_ROOT_PASSWORD": getDbRootPassword(),
},
}
if (db == "mysql:8.0"):
service["command"] = ["--default-authentication-plugin=mysql_native_password"]
return [service]
if dbName == "postgres":
return [{
"name": dbName,
"image": db,
"environment": {
"POSTGRES_USER": getDbUsername(db),
"POSTGRES_PASSWORD": getDbPassword(db),
"POSTGRES_DB": getDbDatabase(db),
},
}]
if dbName == "oracle":
return [{
"name": dbName,
"image": OC_CI_ORACLE_XE,
"environment": {
"ORACLE_USER": getDbUsername(db),
"ORACLE_PASSWORD": getDbPassword(db),
"ORACLE_DB": getDbDatabase(db),
"ORACLE_DISABLE_ASYNCH_IO": "true",
},
}]
return []
def browserService(browser):
if browser == "chrome":
return [{
"name": "selenium",
"image": SELENIUM_STANDALONE_CHROME_DEBUG,
"environment": {
"JAVA_OPTS": "-Dselenium.LOGGER.level=WARNING",
},
"volumes": [{
"name": "downloads",
"path": "%s" % dir["browserService"],
}],
}]
if browser == "firefox":
return [{
"name": "selenium",
"image": SELENIUM_STANDALONE_FIREFOX_DEBUG,
"environment": {
"JAVA_OPTS": "-Dselenium.LOGGER.level=WARNING",
"SE_OPTS": "-enablePassThrough false",
},
"volumes": [{
"name": "downloads",
"path": "%s" % dir["browserService"],
}],
}]
return []
def waitForBrowserService(browser):
if browser in ["chrome", "firefox"]:
return [{
"name": "wait-for-selenium",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it selenium:4444 -t 600",
],
}]
return []
def emailService(emailNeeded):
if emailNeeded:
return [{
"name": "email",
"image": INBUCKET_INBUCKET,
}]
return []
def waitForEmailService(emailNeeded):
if emailNeeded:
return [{
"name": "wait-for-email",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it email:9000 -t 600",
],
}]
return []
def ldapService(ldapNeeded):
if ldapNeeded:
return [{
"name": "ldap",
"image": OSIXIA_OPENLDAP,
"environment": {
"LDAP_DOMAIN": "owncloud.com",
"LDAP_ORGANISATION": "owncloud",
"LDAP_ADMIN_PASSWORD": "admin",
"LDAP_TLS_VERIFY_CLIENT": "never",
},
}]
return []
def proxyService(proxyNeeded):
if proxyNeeded:
return [{
"name": "proxy",
"image": POTTAVA_PROXY,
"environment": {
"PROXY_URL": "http://server",
},
}]
return []
def webdavService(needed):
if not needed:
return []
return [{
"name": "webdav",
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"environment": {
"APACHE_CONFIG_TEMPLATE": "webdav",
},
"command": [
"/usr/local/bin/apachectl",
"-D",
"FOREGROUND",
],
}]
def sambaService(needed):
if not needed:
return []
return [{
"name": "samba",
"image": OC_CI_SAMBA,
"command": [
"-u",
"test;test",
"-s",
"public;/tmp;yes;no;no;test;none;test",
"-S",
],
}]
def sftpService(needed):
if not needed:
return []
# 'test:12345:1001::upload'
# Creates a user 'test' with password '12345', UID '1001'
# The user has a folder called 'upload' that they can write to.
# The tests depend on the 'upload' folder already existing, because
# "Just remember that the users can't create new files directly under their
# own home directory, so make sure there are at least one subdirectory
# if you want them to upload files" https://hub.docker.com/r/atmoz/sftp/
# Also see apps/files_external/tests/env/start-sftp-atmoz.sh where the
# docker image can be started "locally".
return [{
"name": "sftp",
"image": ATMOZ_SFTP,
"environment": {
"SFTP_USERS": "test:12345:1001::upload",
},
}]
def scalityService(scalityS3):
if not scalityS3:
return []
return [{
"name": "scality",
"image": OC_CI_SCALITY_S3SERVER,
"environment": {
"HOST_NAME": "scality",
},
}]
def cephService(cephS3):
if not cephS3:
return []
return [{
"name": "ceph",
"image": OC_CI_CEPH,
"environment": {
"NETWORK_AUTO_DETECT": "4",
"RGW_NAME": "ceph",
"CEPH_DEMO_UID": "owncloud",
"CEPH_DEMO_ACCESS_KEY": "owncloud123456",
"CEPH_DEMO_SECRET_KEY": "secret123456",
},
}]
def owncloudService(phpVersion, name, pathOfServerUnderTest, ssl):
if ssl:
environment = {
"APACHE_WEBROOT": pathOfServerUnderTest,
"APACHE_CONFIG_TEMPLATE": "ssl",
"APACHE_SSL_CERT_CN": name,
"APACHE_SSL_CERT": "%s/%s.crt" % (dir["base"], name),
"APACHE_SSL_KEY": "%s/%s.key" % (dir["base"], name),
"APACHE_LOGGING_PATH": "/dev/null",
}
else:
environment = {
"APACHE_WEBROOT": pathOfServerUnderTest,
"APACHE_LOGGING_PATH": "/dev/null",
}
return [{
"name": name,
"image": OC_CI_PHP % phpVersion,
"environment": environment,
"command": [
"/usr/local/bin/apachectl",
"-e",
"debug",
"-D",
"FOREGROUND",
],
}]
def getShortDbNameAndVersion(db):
return "%s%s" % (getDbShortName(db), getDbVersion(db))
def getDbName(db):
return db.partition(":")[0]
def getDbVersion(db):
return db.partition(":")[2]
def getDbUsername(db):
name = getDbName(db)
# The Oracle image has the Db Username hardcoded
if name == "oracle":
return "autotest"
return "owncloud"
def getDbPassword(db):
name = getDbName(db)
# The Oracle image has the Db Password hardcoded
if name == "oracle":
return "owncloud"
return "owncloud"
def getDbRootPassword():
return "owncloud"
def getDbDatabase(db):
name = getDbName(db)
# The Oracle image has the Db Name hardcoded
if name == "oracle":
return "XE"
return "owncloud"
def getDbType(db):
dbName = getDbName(db)
if dbName == "postgres":
return "pgsql"
if dbName == "oracle":
return "oci"
return dbName
def getDbShortName(db):
dbName = getDbName(db)
if dbName == "postgres":
return "pgsql"
if dbName == "oracle":
return "oci"
if dbName == "mariadb":
return "maria"
return dbName
def cacheRestore():
return [{
"name": "cache-restore",
"image": PLUGINS_S3_CACHE,
"settings": {
"access_key": {
"from_secret": "cache_s3_access_key",
},
"endpoint": {
"from_secret": "cache_s3_server",
},
"restore": True,
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
"when": {
"instance": [
"drone.owncloud.services",
"drone.owncloud.com",
],
},
}]
def cacheClearOnEventPush(phpVersion):
return [{
"name": "cache-clear",
"image": OC_CI_PHP % phpVersion,
"commands": [
"rm -Rf %s/.cache/composer" % dir["server"],
"rm -Rf %s/.cache/yarn" % dir["server"],
],
"when": {
"event": [
"push",
],
"instance": [
"drone.owncloud.services",
"drone.owncloud.com",
],
},
}]
def cacheRebuildOnEventPush():
return [{
"name": "cache-rebuild",
"image": PLUGINS_S3_CACHE,
"settings": {
"access_key": {
"from_secret": "cache_s3_access_key",
},
"endpoint": {
"from_secret": "cache_s3_server",
},
"mount": [
".cache",
],
"rebuild": True,
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
"when": {
"event": [
"push",
],
"instance": [
"drone.owncloud.services",
"drone.owncloud.com",
],
},
}]
def cacheFlushOnEventPush():
return [{
"name": "cache-flush",
"image": PLUGINS_S3_CACHE,
"settings": {
"access_key": {
"from_secret": "cache_s3_access_key",
},
"endpoint": {
"from_secret": "cache_s3_server",
},
"flush": True,
"flush_age": "14",
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
},
"when": {
"event": [
"push",
],
"instance": [
"drone.owncloud.services",
"drone.owncloud.com",
],
},
}]
def composerInstall(phpVersion):
return [{
"name": "composer-install",
"image": OC_CI_PHP % phpVersion,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make install-composer-deps",
],
}]
def vendorbinCodestyle(phpVersion):
return [{
"name": "vendorbin-codestyle",
"image": OC_CI_PHP % phpVersion,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make vendor-bin-codestyle",
],
}]
def vendorbinCodesniffer(phpVersion):
return [{
"name": "vendorbin-codesniffer",
"image": OC_CI_PHP % phpVersion,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make vendor-bin-codesniffer",
],
}]
def vendorbinPhan(phpVersion):
return [{
"name": "vendorbin-phan",
"image": OC_CI_PHP % phpVersion,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make vendor-bin-phan",
],
}]
def vendorbinPhpstan(phpVersion):
return [{
"name": "vendorbin-phpstan",
"image": OC_CI_PHP % phpVersion,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make vendor-bin-phpstan",
],
}]
def vendorbinBehat():
return [{
"name": "vendorbin-behat",
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"environment": {
"COMPOSER_HOME": "%s/.cache/composer" % dir["server"],
},
"commands": [
"make vendor-bin-behat",
],
}]
def yarnInstall():
return [{
"name": "yarn-install",
"image": OC_CI_NODEJS % DEFAULT_NODEJS_VERSION,
"environment": {
"NPM_CONFIG_CACHE": "%s/.cache/npm" % dir["server"],
"YARN_CACHE_FOLDER": "%s/.cache/yarn" % dir["server"],
"bower_storage__packages": "%s/.cache/bower" % dir["server"],
},
"commands": [
"make install-nodejs-deps",
],
}]
def davInstall(phpVersion, scriptPath):
return [{
"name": "dav-install",
"image": OC_CI_PHP % phpVersion,
"commands": [
"bash %s/install.sh" % scriptPath,
],
}]
def setupLocalStorage(phpVersion):
return [{
"name": "setup-storage",
"image": OC_CI_PHP % phpVersion,
"environment": {
"OC_PASS": "123456",
},
"commands": [
"mkdir -p %s/work/local_storage" % dir["server"],
"php occ app:enable files_external",
"php occ config:system:set files_external_allow_create_new_local --value=true",
"php occ config:app:set core enable_external_storage --value=yes",
"php occ files_external:create local_storage local null::null -c datadir=%s/work/local_storage" % dir["server"],
"php occ user:add --password-from-env user1",
],
}]
def createShare(phpVersion):
return [{
"name": "create-share",
"image": OC_CI_PHP % phpVersion,
"commands": [
'curl -k -s -u user1:123456 -X MKCOL "https://server/remote.php/webdav/new_folder"',
'curl -k -s -u user1:123456 "https://server/ocs/v2.php/apps/files_sharing/api/v1/shares" --data "path=/new_folder&shareType=0&permissions=15&name=new_folder&shareWith=admin"',
'echo -n "PUBLIC_TOKEN=" > .env',
'curl -k -s -u user1:123456 "https://server/ocs/v2.php/apps/files_sharing/api/v1/shares" --data "path=/new_folder&shareType=3&permissions=15&name=new_folder" | grep token | cut -d">" -f2 | cut -d"<" -f1 >> .env',
],
}]
def installExtraApps(phpVersion, extraApps, pathOfServerUnderTest):
commandArray = []
for app, command in extraApps.items():
commandArray.append("ls %s/apps/%s || git clone https://github.com/owncloud/%s.git %s/apps/%s" % (pathOfServerUnderTest, app, app, pathOfServerUnderTest, app))
if (command != ""):
commandArray.append("cd %s/apps/%s" % (pathOfServerUnderTest, app))
commandArray.append(command)
commandArray.append("cd %s" % pathOfServerUnderTest)
commandArray.append("php occ a:l")
commandArray.append("php occ a:e %s" % app)
commandArray.append("php occ a:l")
if (commandArray == []):
return []
return [{
"name": "install-extra-apps",
"image": OC_CI_PHP % phpVersion,
"commands": commandArray,
}]
def databaseServiceForFederation(db, suffix):
dbName = getDbName(db)
if dbName not in ["mariadb", "mysql"]:
print("Not implemented federated database for ", dbName)
return []
service = {
"name": dbName + suffix,
"image": db,
"environment": {
"MYSQL_USER": getDbUsername(db),
"MYSQL_PASSWORD": getDbPassword(db),
"MYSQL_DATABASE": getDbDatabase(db) + suffix,
"MYSQL_ROOT_PASSWORD": getDbRootPassword(),
},
}
if (db == "mysql:8.0"):
service["command"] = ["--default-authentication-plugin=mysql_native_password"]
return [service]
def installServer(phpVersion, db, logLevel = "2", ssl = False, federatedServerNeeded = False, proxyNeeded = False):
return [{
"name": "install-server",
"image": OC_CI_PHP % phpVersion,
"environment": {
"DB_TYPE": getDbName(db),
"DB_USERNAME": getDbUsername(db),
"DB_PASSWORD": getDbPassword(db),
"DB_NAME": getDbDatabase(db),
},
"commands": [
"bash tests/drone/install-server.sh",
"php occ a:l",
"php occ config:system:set trusted_domains 1 --value=server",
] + ([
"php occ config:system:set trusted_domains 2 --value=federated",
"php occ config:system:set csrf.disabled --value=true",
] if federatedServerNeeded else []) + [
] + ([
"php occ config:system:set trusted_domains 3 --value=proxy",
] if proxyNeeded else []) + [
"php occ log:manage --level %s" % logLevel,
"php occ config:list",
] + ([
"php occ security:certificates:import %s/server.crt" % dir["base"],
] if ssl else []) + ([
"php occ security:certificates:import %s/federated.crt" % dir["base"],
] if federatedServerNeeded and ssl else []) + [
"php occ security:certificates",
],
}]
def enableAppsForPhpStan(phpVersion):
return [{
"name": "enable-apps-for-phpstan",
"image": OC_CI_PHP % phpVersion,
"commands": [
# files_external can be disabled.
# We need it to be enabled so that the PHP static analyser can find classes in it.
"php occ a:e files_external",
"php occ a:l",
],
}]
def installAndConfigureFederated(ctx, federatedServerVersion, phpVersion, logLevel, protocol, db, dbSuffix = "fed"):
return [
installFederated(ctx, federatedServerVersion, db, dbSuffix),
configureFederated(phpVersion, logLevel, protocol),
]
def installFederated(ctx, federatedServerVersion, db, dbSuffix = "fed"):
host = getDbName(db)
dbType = host
username = getDbUsername(db)
password = getDbPassword(db)
database = getDbDatabase(db) + dbSuffix
if host == "mariadb":
dbType = "mysql"
elif host == "postgres":
dbType = "pgsql"
elif host == "oracle":
dbType = "oci"
installerSettings = {
"core_path": dir["federated"],
"db_type": dbType,
"db_name": database,
"db_host": host + dbSuffix,
"db_username": username,
"db_password": password,
}
if (federatedServerVersion == "git"):
if (ctx.build.source_repo == ctx.repo.slug):
# The PR comes from a branch that is in the same repo
# So use that branch for installing the federated server
installerSettings["git_reference"] = ctx.build.source
else:
# The PR comes from a branch that is in some other repo
# e.g. a community contribution from a fork
# Rather than jumping through hoops to find that code,
# install the federated server from owncloud/core master
installerSettings["git_reference"] = "master"
else:
installerSettings["version"] = federatedServerVersion
return {
"name": "install-federated",
"image": OC_CI_CORE_NODEJS,
"settings": installerSettings,
}
def configureFederated(phpVersion, logLevel, protocol):
return {
"name": "configure-federated",
"image": OC_CI_PHP % phpVersion,
"commands": [
"cd %s" % dir["federated"],
"php occ a:l",
"php occ a:e testing",
"php occ a:l",
"php occ config:system:set trusted_domains 1 --value=server",
"php occ config:system:set trusted_domains 2 --value=federated",
"php occ log:manage --level %s" % logLevel,
"php occ config:list",
'echo "export TEST_SERVER_FED_URL=%s://federated" > %s/saved-settings.sh' % (protocol, dir["base"]),
"php occ security:certificates:import %s/server.crt" % dir["base"],
"php occ security:certificates:import %s/federated.crt" % dir["base"],
"php occ security:certificates",
],
}
def setupCeph(phpVersion, cephS3):
if not cephS3:
return []
return [
{
"name": "wait-for-ceph",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it ceph:80 -t 600",
],
},
{
"name": "setup-ceph",
"image": OC_CI_PHP % phpVersion,
"commands": [
"cd %s/apps/files_primary_s3" % dir["server"],
"cp tests/drone/ceph.config.php %s/config" % dir["server"],
"cd /var/www/owncloud/server",
"./apps/files_primary_s3/tests/drone/create-bucket.sh",
],
},
]
def setupScality(phpVersion, scalityS3):
if type(scalityS3) == "bool":
if scalityS3:
# specify an empty dict that will get the defaults
scalityS3 = {}
else:
return []
specialConfig = "." + scalityS3["config"] if "config" in scalityS3 else ""
configFile = "scality%s.config.php" % specialConfig
createExtraBuckets = scalityS3["createExtraBuckets"] if "createExtraBuckets" in scalityS3 else False
return [
{
"name": "wait-for-scality",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it scality:8000 -t 600",
],
},
{
"name": "setup-scality",
"image": OC_CI_PHP % phpVersion,
"commands": [
"cp %s/apps/files_primary_s3/tests/drone/%s %s/config" % (dir["server"], configFile, dir["server"]),
"php occ s3:create-bucket owncloud --accept-warning",
] + ([
"for I in $(seq 1 9); do php ./occ s3:create-bucket owncloud$I --accept-warning; done",
] if createExtraBuckets else []),
},
]
def fixPermissions(phpVersion, federatedServerNeeded, selUserNeeded = False, pathOfServerUnderTest = dir["server"]):
return [{
"name": "fix-permissions",
"image": OC_CI_PHP % phpVersion,
"commands": [
"chown -R www-data %s" % dir["server"],
] + ([
"chown -R www-data %s" % pathOfServerUnderTest,
] if (pathOfServerUnderTest != dir["server"]) else []) + ([
"chown -R www-data %s" % dir["federated"],
] if federatedServerNeeded else []) + ([
"chmod 777 %s" % dir["browserService"],
] if selUserNeeded else []),
"volumes": [{
"name": "downloads",
"path": "%s" % dir["browserService"],
}],
}]
def waitForServer(federatedServerNeeded):
return [{
"name": "wait-for-server",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it server:80 -t 600",
] + ([
"wait-for -it federated:80 -t 600",
] if federatedServerNeeded else []),
}]
def owncloudLog(server, folder):
return [{
"name": "owncloud-log-%s" % server,
"image": OC_UBUNTU,
"detach": True,
"commands": [
"tail -f %s/data/owncloud.log" % folder,
],
}]
def owncloudDockerService(ocDockerService):
if not ocDockerService:
return []
db = "postgres"
domainForOcDocker = "oc-server"
return [
{
"name": domainForOcDocker,
"image": OC_SERVER,
"environment": {
"OWNCLOUD_VERSION": "latest",
"OWNCLOUD_DOMAIN": domainForOcDocker,
"OWNCLOUD_ADMIN_USERNAME": "admin",
"OWNCLOUD_ADMIN_PASSWORD": "admin",
"HTTP_PORT": "8080",
"OWNCLOUD_REDIS_ENABLED": "true",
"OWNCLOUD_REDIS_HOST": "redis",
"OWNCLOUD_DB_TYPE": getDbType(db),
"OWNCLOUD_DB_NAME": getDbUsername(db),
"OWNCLOUD_DB_USERNAME": getDbUsername(db),
"OWNCLOUD_DB_PASSWORD": getDbPassword(db),
"OWNCLOUD_DB_HOST": getDbName(db),
"OWNCLOUD_TRUSTED_DOMAINS": domainForOcDocker,
},
},
] + databaseService(db)
def redisService(redisService):
if not redisService:
return []
return [{
"name": "redis",
"image": WEBHIPPIE_REDIS,
"environment": {
"REDIS_DATABASES": 1,
},
}]
def dependsOn(earlierStages, nextStages):
for earlierStage in earlierStages:
for nextStage in nextStages:
nextStage["depends_on"].append(earlierStage["name"])
def installCoreFromTarball(version, db, logLevel = "2", ssl = False, federatedServerNeeded = False, proxyNeeded = False, pathOfServerUnderTest = dir["tarballServer"]):
host = getDbName(db)
dbType = host
username = getDbUsername(db)
password = getDbPassword(db)
database = getDbDatabase(db)
if host == "mariadb":
dbType = "mysql"
if host == "postgres":
dbType = "pgsql"
if host == "oracle":
dbType = "oci"
return [{
"name": "install-tarball",
"image": OC_CI_CORE_NODEJS,
"settings": {
"version": version,
"core_path": pathOfServerUnderTest,
"db_type": dbType,
"db_name": database,
"db_host": host,
"db_username": username,
"db_password": password,
},
}, {
"name": "configure-tarball",
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"commands": [
"cd %s" % pathOfServerUnderTest,
"php occ a:l",
"php occ a:e testing",
"php occ a:l",
"php occ config:system:set trusted_domains 1 --value=server",
] + ([
"php occ config:system:set trusted_domains 2 --value=federated",
"php occ config:system:set csrf.disabled --value=true",
] if federatedServerNeeded else []) + [
] + ([
"php occ config:system:set trusted_domains 3 --value=proxy",
] if proxyNeeded else []) + [
"php occ log:manage --level %s" % logLevel,
"php occ config:list",
] + ([
"php occ security:certificates:import %s/server.crt" % dir["base"],
] if ssl else []) + ([
"php occ security:certificates:import %s/federated.crt" % dir["base"],
] if federatedServerNeeded and ssl else []) + [
"php occ security:certificates",
],
}]
def installFederatedFromTarball(federatedServerVersion, phpVersion, logLevel, protocol, db, dbSuffix = "-federated"):
host = getDbName(db)
dbType = host
username = getDbUsername(db)
password = getDbPassword(db)
database = getDbDatabase(db) + dbSuffix
if host == "mariadb":
dbType = "mysql"
elif host == "postgres":
dbType = "pgsql"
elif host == "oracle":
dbType = "oci"
return [
{
"name": "install-federated",
"image": OC_CI_CORE_NODEJS,
"settings": {
"version": federatedServerVersion,
"core_path": dir["federated"],
"db_type": "mysql",
"db_name": database,
"db_host": host + dbSuffix,
"db_username": username,
"db_password": password,
},
},
{
"name": "configure-federation",
"image": OC_CI_PHP % phpVersion,
"commands": [
'echo "export TEST_SERVER_FED_URL=%s://federated" > %s/saved-settings.sh' % (protocol, dir["base"]),
"cd %s" % dir["federated"],
"php occ a:l",
"php occ a:e testing",
"php occ a:l",
"php occ config:system:set trusted_domains 1 --value=server",
"php occ config:system:set trusted_domains 2 --value=federated",
"php occ log:manage --level %s" % logLevel,
"php occ config:list",
"php occ security:certificates:import %s/server.crt" % dir["base"],
"php occ security:certificates:import %s/federated.crt" % dir["base"],
"php occ security:certificates",
],
},
]
def installTestRunner(ctx, phpVersion):
return [{
"name": "install-testrunner",
"image": OC_CI_PHP % phpVersion,
"commands": [
"mkdir /tmp/testrunner",
"git clone -b %s --depth=1 https://github.com/owncloud/core.git /tmp/testrunner" % ctx.build.source if ctx.build.event == "pull_request" else "master",
"rsync -aIX /tmp/testrunner/tests %s/tests" % dir["server"],
],
}]
def checkStarlark():
return [{
"kind": "pipeline",
"type": "docker",
"name": "check-starlark",
"steps": [
{
"name": "format-check-starlark",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=check .drone.star",
],
},
{
"name": "show-diff",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=fix .drone.star",
"git diff",
],
"when": {
"status": [
"failure",
],
},
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
],
},
}]
def checkGitCommit():
return [{
"kind": "pipeline",
"type": "docker",
"name": "check-git-commit-messages",
"steps": [
{
"name": "format-check-git-commit",
"image": "aevea/commitsar:latest",
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
],
},
}]
def skipIfUnchanged(ctx, type):
if ("full-ci" in ctx.build.title.lower()):
return []
skip_step = {
"name": "skip-if-unchanged",
"image": OC_CI_DRONE_SKIP_PIPELINE,
"when": {
"event": [
"pull_request",
],
},
}
# these files are not relevant for test pipelines
# if only files in this array are changed, then don't even run the "lint"
# pipelines (like code-style, phan, phpstan...)
allow_skip_if_changed = [
"^.github/.*",
"^changelog/.*",
"CHANGELOG.md",
"CONTRIBUTING.md",
"LICENSE",
"LICENSE.md",
"README.md",
]
if type == "lint":
skip_step["settings"] = {
"ALLOW_SKIP_CHANGED": allow_skip_if_changed,
}
return [skip_step]
if type == "acceptance-tests":
# if any of these files are touched then run all acceptance tests
acceptance_files = [
"^tests/acceptance/.*",
"^tests/drone/.*",
"^tests/data/.*",
"^tests/TestHelpers/.*",
"^tests/enable_all.php",
"^tests/preseed-config.php",
"^vendor-bin/behat/.*",
"^apps/[a-z_]*/ajax/.*",
"^apps/[a-z_]*/appinfo/.*",
"^apps/[a-z_]*/bin/.*",
"^apps/[a-z_]*/css/.*",
"^apps/[a-z_]*/js/.*",
"^apps/[a-z_]*/lib/.*",
"^apps/[a-z_]*/templates/.*",
"^apps/files_external/3rdparty/.*",
"^core/.*",
"^lib/.*",
"^l10n/.*",
"^ocm-provider/.*",
"^ocs/.*",
"^ocs-provider/.*",
"^resources/.*",
"^settings/.*",
"composer.json",
"composer.lock",
"Makefile",
"package.json",
"package-lock.json",
"yarn.lock",
]
skip_step["settings"] = {
"DISALLOW_SKIP_CHANGED": acceptance_files,
}
return [skip_step]
if type == "unit-tests":
# if any of these files are touched then run all unit tests
unit_files = [
"^tests/apps/.*",
"^tests/core/.*",
"^tests/data/.*",
"^tests/docs/.*",
"^tests/lib/.*",
"^tests/Settings/.*",
"^tests/TestHelpers/.*",
"^tests/apps.php",
"^tests/bootstrap.php",
"^tests/enable_all.php",
"^tests/phpunit-autotest.xml",
"^tests/phpunit-autotest-external.xml",
"^tests/preseed-config.php",
"^tests/startsessionlistener.php",
"^apps/.*",
"^core/.*",
"^lib/.*",
"^l10n/.*",
"^ocm-provider/.*",
"^ocs/.*",
"^ocs-provider/.*",
"^resources/.*",
"^settings/.*",
"composer.json",
"composer.lock",
"Makefile",
"package.json",
"package-lock.json",
"phpunit.xml",
"yarn.lock",
"sonar-project.properties",
]
skip_step["settings"] = {
"DISALLOW_SKIP_CHANGED": unit_files,
}
return [skip_step]
return []
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mamh-mixed/owncloud-core.git
git@gitee.com:mamh-mixed/owncloud-core.git
mamh-mixed
owncloud-core
owncloud-core
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385