mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-25 05:28:20 -05:00
a3a4232387
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
729 lines
16 KiB
Python
729 lines
16 KiB
Python
def main(ctx):
|
|
before = [
|
|
testing(ctx),
|
|
]
|
|
|
|
stages = [
|
|
docker(ctx, 'amd64'),
|
|
docker(ctx, 'arm64'),
|
|
docker(ctx, 'arm'),
|
|
binary(ctx, 'linux'),
|
|
binary(ctx, 'darwin'),
|
|
binary(ctx, 'windows'),
|
|
]
|
|
|
|
after = [
|
|
manifest(ctx),
|
|
changelog(ctx),
|
|
readme(ctx),
|
|
badges(ctx),
|
|
website(ctx),
|
|
]
|
|
|
|
return before + stages + after
|
|
|
|
def testing(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'testing',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'generate',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make generate',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'vet',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make vet',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'staticcheck',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make staticcheck',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'lint',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make lint',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'build',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make build',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'test',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make test',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'codacy',
|
|
'image': 'plugins/codacy:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'token': {
|
|
'from_secret': 'codacy_token',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
'name': 'reva-server',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'detach': True,
|
|
'environment' : {
|
|
'REVA_USERS_DRIVER': 'ldap',
|
|
'REVA_STORAGE_HOME_EXPOSE_DATA_SERVER': 1,
|
|
'REVA_STORAGE_OC_EXPOSE_DATA_SERVER': 1,
|
|
'REVA_LDAP_HOSTNAME': 'ldap',
|
|
'REVA_STORAGE_HOME_DATA_TEMP_FOLDER': '/srv/app/tmp/',
|
|
'REVA_STORAGE_LOCAL_ROOT': '/srv/app/tmp/reva/root',
|
|
'REVA_STORAGE_OWNCLOUD_DATADIR': '/srv/app/tmp/reva/data',
|
|
'REVA_STORAGE_OC_DATA_TEMP_FOLDER': '/srv/app/tmp/',
|
|
},
|
|
'commands': [
|
|
'mkdir -p /srv/app/tmp/reva',
|
|
'bin/ocis-reva gateway &',
|
|
'bin/ocis-reva users &',
|
|
'bin/ocis-reva auth-basic &',
|
|
'bin/ocis-reva auth-bearer &',
|
|
'bin/ocis-reva sharing &',
|
|
'bin/ocis-reva storage-root &',
|
|
'bin/ocis-reva storage-home &',
|
|
'bin/ocis-reva storage-home-data &',
|
|
'bin/ocis-reva storage-oc &',
|
|
'bin/ocis-reva storage-oc-data &',
|
|
'bin/ocis-reva frontend'
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
]
|
|
},
|
|
{
|
|
'name': 'acceptance-tests',
|
|
'image': 'owncloudci/php:7.2',
|
|
'pull': 'always',
|
|
'environment' : {
|
|
'TEST_SERVER_URL': 'http://reva-server:9140',
|
|
'BEHAT_FILTER_TAGS': '~@skipOnOcis&&~@skipOnLDAP&&@TestAlsoOnExternalUserBackend',
|
|
'REVA_LDAP_HOSTNAME':'ldap',
|
|
'TEST_EXTERNAL_USER_BACKENDS':'true',
|
|
'TEST_OCIS':'true',
|
|
'OCIS_REVA_DATA_ROOT': '/srv/app/tmp/reva/'
|
|
},
|
|
'commands': [
|
|
'git clone -b master --depth=1 https://github.com/owncloud/core.git /srv/app/testrunner',
|
|
'cd /srv/app/testrunner',
|
|
'make test-acceptance-api'
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
]
|
|
},
|
|
],
|
|
'services': [
|
|
{
|
|
'name': 'ldap',
|
|
'image': 'osixia/openldap',
|
|
'pull': 'always',
|
|
'environment': {
|
|
'LDAP_DOMAIN': 'owncloud.com',
|
|
'LDAP_ORGANISATION': 'owncloud',
|
|
'LDAP_ADMIN_PASSWORD': 'admin',
|
|
'LDAP_TLS_VERIFY_CLIENT': 'never',
|
|
'HOSTNAME': 'ldap'
|
|
},
|
|
},
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'temp': {},
|
|
},
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def docker(ctx, arch):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': arch,
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': arch,
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'generate',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make generate',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'build',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make build',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'dryrun',
|
|
'image': 'plugins/docker:18.09',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'dry_run': True,
|
|
'tags': 'linux-%s' % (arch),
|
|
'dockerfile': 'docker/Dockerfile.linux.%s' % (arch),
|
|
'repo': ctx.repo.slug,
|
|
},
|
|
'when': {
|
|
'ref': {
|
|
'include': [
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
'name': 'docker',
|
|
'image': 'plugins/docker:18.09',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'username': {
|
|
'from_secret': 'docker_username',
|
|
},
|
|
'password': {
|
|
'from_secret': 'docker_password',
|
|
},
|
|
'auto_tag': True,
|
|
'auto_tag_suffix': 'linux-%s' % (arch),
|
|
'dockerfile': 'docker/Dockerfile.linux.%s' % (arch),
|
|
'repo': ctx.repo.slug,
|
|
},
|
|
'when': {
|
|
'ref': {
|
|
'exclude': [
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'temp': {},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'testing',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def binary(ctx, name):
|
|
if ctx.build.event == "tag":
|
|
settings = {
|
|
'endpoint': {
|
|
'from_secret': 's3_endpoint',
|
|
},
|
|
'access_key': {
|
|
'from_secret': 'aws_access_key_id',
|
|
},
|
|
'secret_key': {
|
|
'from_secret': 'aws_secret_access_key',
|
|
},
|
|
'bucket': {
|
|
'from_secret': 's3_bucket',
|
|
},
|
|
'path_style': True,
|
|
'strip_prefix': 'dist/release/',
|
|
'source': 'dist/release/*',
|
|
'target': '/ocis/%s/%s' % (ctx.repo.name.replace("ocis-", ""), ctx.build.ref.replace("refs/tags/v", "")),
|
|
}
|
|
else:
|
|
settings = {
|
|
'endpoint': {
|
|
'from_secret': 's3_endpoint',
|
|
},
|
|
'access_key': {
|
|
'from_secret': 'aws_access_key_id',
|
|
},
|
|
'secret_key': {
|
|
'from_secret': 'aws_secret_access_key',
|
|
},
|
|
'bucket': {
|
|
'from_secret': 's3_bucket',
|
|
},
|
|
'path_style': True,
|
|
'strip_prefix': 'dist/release/',
|
|
'source': 'dist/release/*',
|
|
'target': '/ocis/%s/testing' % (ctx.repo.name.replace("ocis-", "")),
|
|
}
|
|
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': name,
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'generate',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make generate',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'build',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make release-%s' % (name),
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'finish',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make release-finish',
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'path': '/srv/app',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
'name': 'upload',
|
|
'image': 'plugins/s3:1',
|
|
'pull': 'always',
|
|
'settings': settings,
|
|
'when': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
},
|
|
{
|
|
'name': 'changelog',
|
|
'image': 'toolhippie/calens:latest',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'calens --version %s -o dist/CHANGELOG.md' % ctx.build.ref.replace("refs/tags/v", "").split("-")[0],
|
|
],
|
|
'when': {
|
|
'ref': [
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
},
|
|
{
|
|
'name': 'release',
|
|
'image': 'plugins/github-release:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'api_key': {
|
|
'from_secret': 'github_token',
|
|
},
|
|
'files': [
|
|
'dist/release/*',
|
|
],
|
|
'title': ctx.build.ref.replace("refs/tags/", ""),
|
|
'note': 'dist/CHANGELOG.md',
|
|
'overwrite': True,
|
|
},
|
|
'when': {
|
|
'ref': [
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
},
|
|
],
|
|
'volumes': [
|
|
{
|
|
'name': 'gopath',
|
|
'temp': {},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'testing',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def manifest(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'manifest',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'execute',
|
|
'image': 'plugins/manifest:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'username': {
|
|
'from_secret': 'docker_username',
|
|
},
|
|
'password': {
|
|
'from_secret': 'docker_password',
|
|
},
|
|
'spec': 'docker/manifest.tmpl',
|
|
'auto_tag': True,
|
|
'ignore_missing': True,
|
|
},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'amd64',
|
|
'arm64',
|
|
'arm',
|
|
'linux',
|
|
'darwin',
|
|
'windows',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def changelog(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'changelog',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'clone': {
|
|
'disable': True,
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'clone',
|
|
'image': 'plugins/git-action:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'actions': [
|
|
'clone',
|
|
],
|
|
'remote': 'https://github.com/%s' % (ctx.repo.slug),
|
|
'branch': ctx.build.branch if ctx.build.event == 'pull_request' else 'master',
|
|
'path': '/drone/src',
|
|
'netrc_machine': 'github.com',
|
|
'netrc_username': {
|
|
'from_secret': 'github_username',
|
|
},
|
|
'netrc_password': {
|
|
'from_secret': 'github_token',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
'name': 'generate',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make changelog',
|
|
],
|
|
},
|
|
{
|
|
'name': 'output',
|
|
'image': 'webhippie/golang:1.13',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'cat CHANGELOG.md',
|
|
],
|
|
},
|
|
{
|
|
'name': 'publish',
|
|
'image': 'plugins/git-action:1',
|
|
'pull': 'always',
|
|
'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': [
|
|
'manifest',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def readme(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'readme',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'execute',
|
|
'image': 'sheogorath/readme-to-dockerhub:latest',
|
|
'pull': 'always',
|
|
'environment': {
|
|
'DOCKERHUB_USERNAME': {
|
|
'from_secret': 'docker_username',
|
|
},
|
|
'DOCKERHUB_PASSWORD': {
|
|
'from_secret': 'docker_password',
|
|
},
|
|
'DOCKERHUB_REPO_PREFIX': ctx.repo.namespace,
|
|
'DOCKERHUB_REPO_NAME': ctx.repo.name,
|
|
'SHORT_DESCRIPTION': 'Docker images for %s' % (ctx.repo.name),
|
|
'README_PATH': 'README.md',
|
|
},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'changelog',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def badges(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'badges',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'execute',
|
|
'image': 'plugins/webhook:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'urls': {
|
|
'from_secret': 'microbadger_url',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'readme',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/tags/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
def website(ctx):
|
|
return {
|
|
'kind': 'pipeline',
|
|
'type': 'docker',
|
|
'name': 'website',
|
|
'platform': {
|
|
'os': 'linux',
|
|
'arch': 'amd64',
|
|
},
|
|
'steps': [
|
|
{
|
|
'name': 'generate',
|
|
'image': 'webhippie/hugo:latest',
|
|
'pull': 'always',
|
|
'commands': [
|
|
'make docs',
|
|
],
|
|
},
|
|
{
|
|
'name': 'publish',
|
|
'image': 'plugins/gh-pages:1',
|
|
'pull': 'always',
|
|
'settings': {
|
|
'username': {
|
|
'from_secret': 'github_username',
|
|
},
|
|
'password': {
|
|
'from_secret': 'github_token',
|
|
},
|
|
'pages_directory': 'docs/public/',
|
|
'temporary_base': 'tmp/',
|
|
},
|
|
'when': {
|
|
'ref': {
|
|
'exclude': [
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
'depends_on': [
|
|
'badges',
|
|
],
|
|
'trigger': {
|
|
'ref': [
|
|
'refs/heads/master',
|
|
'refs/pull/**',
|
|
],
|
|
},
|
|
}
|