This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Go Lang version: | |
| local golang = "golang:1.12"; | |
| # Docker plugin version: | |
| local plg_docker = "plugins/docker:17.12"; | |
| # Helper funcions | |
| local splitter(vars) = if vars != "" then std.split(vars, ";"); | |
| local splitter_env(vars) = | |
| local objs = std.split(vars, ";"); | |
| local text(obj) = std.format('"%s": "%s"', std.split(obj, ":")); | |
| if vars != "" then std.parseJson('{' + std.join(",", [text(obj) for obj in objs]) + '}'); | |
| # Heavy lifting | |
| local crowdin(name, type, files) = std.prune({ | |
| "name": name, | |
| "image": "jonasfranz/crowdin", | |
| "pull": "always", | |
| "settings": { | |
| "project_identifier": "gitea", | |
| "project_key": { | |
| "from_secret": "crowdin_key" | |
| }, | |
| "files": splitter(files), | |
| "ignore_branch": true, | |
| "download": if type == "dl" then true else false, | |
| "export_dir": if type == "dl" then "options/locale/" | |
| }, | |
| "when": { | |
| "event": [ "push" ], | |
| "branch": [ "master" ] | |
| } | |
| }); | |
| local build(name, image, envs, cmds) = std.prune({ | |
| "name": name, | |
| "image": image, | |
| "pull": "always", | |
| "environment": splitter_env(envs), | |
| "commands": splitter(cmds), | |
| "when": { | |
| "event": [ "push", "tag", "pull_request" ] | |
| } | |
| }); | |
| local test_sql_cmds(name, cmd) = | |
| local sql_type = std.split(name, "-"); | |
| local length = std.length(sql_type) - 1; | |
| local sql = sql_type[length]; | |
| local text1 = ||| | |
| curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | |
| apt-get install -y git-lfs | |
| timeout -s ABRT 20m make test-%s-migration | |
| ||| % sql; | |
| local text2 = "timeout -s ABRT 20m make test-%s" % sql; | |
| local text3 = "timeout -s ABRT 20m integration-test-coverage"; | |
| std.split(if cmd == "sql" then text1 + text2 else text1 + text3, "\n"); | |
| local test(name, envs, cmds, events, branches) = std.prune({ | |
| "name": name, | |
| "image": golang, | |
| "pull": "always", | |
| "environment": splitter_env(envs), | |
| "commands": if (cmds == "sql" || cmds == "sql1") then test_sql_cmds(name, cmds) else splitter(cmds), // not yet available: std.regexFullMatch(cmds, "sql\d*") | |
| "when": { | |
| "event": splitter(events), | |
| "branch": splitter(branches), | |
| } | |
| }); | |
| local bench(name) = { | |
| name: name, | |
| image: golang, | |
| pull: "always", | |
| commands: [ | |
| "make " + name | |
| ], | |
| when: { | |
| event: [ "tag" ] | |
| } | |
| }; | |
| local docker(name, creds, tags, dry_run, default_tags, events, branches) = std.prune({ | |
| "name": name, | |
| "image": plg_docker, | |
| "pull": "always", | |
| "settings": { | |
| "username": { | |
| "from_secret": if creds then "docker_username" | |
| }, | |
| "password": { | |
| "from_secret": if creds then "docker_password" | |
| }, | |
| "repo": "gitea/gitea", | |
| "tags": splitter(tags), | |
| "cache_from": "gitea/gitea", | |
| "dry_run": if dry_run then true, | |
| "default_tags": if default_tags then true | |
| }, | |
| "when": { | |
| "event": splitter(events), | |
| "branch": splitter(branches), | |
| } | |
| }); | |
| local s3(name, bucket, target, events, branches) = std.prune({ | |
| "name": name, | |
| "image": "plugins/s3:1", | |
| "pull": "always", | |
| "settings": { | |
| "endpoint": "https://storage.gitea.io", | |
| "access_key": { | |
| "from_secret": "aws_access_key_id" | |
| }, | |
| "secret_key": { | |
| "from_secret": "aws_secret_access_key" | |
| }, | |
| "bucket": if bucket != "" then bucket, | |
| "acl": "public-read", | |
| "source": "dist/release/*", | |
| "target": target, | |
| "strip_prefix": "dist/release/", | |
| "path_style": true | |
| }, | |
| "when": { | |
| "event": splitter(events), | |
| "branch": splitter(branches), | |
| } | |
| }); | |
| local service(name, image, envs) = std.prune({ | |
| "name": name, | |
| "image": image, | |
| "environment": splitter_env(envs), | |
| "when": { | |
| "event": [ "push", "tag", "pull_request" ] | |
| } | |
| }); | |
| local pipeline(arch, os) = { | |
| "kind": "pipeline", | |
| "name": arch, | |
| "platform": { | |
| "os": os, | |
| "arch": arch | |
| }, | |
| "workspace": { | |
| "base": "/go", | |
| "path": "src/code.gitea.io/gitea" | |
| }, | |
| "steps": [ | |
| { | |
| "name": "fetch-tags", | |
| "image": "docker:git", | |
| "commands": [ | |
| "git fetch --tags --force" | |
| ], | |
| "when": { | |
| "event": { | |
| "exclude": [ "pull_request" ] | |
| } | |
| } | |
| }, | |
| crowdin("download_translations", "dl", ""), | |
| { | |
| "name": "update-translations", | |
| "image": "alpine:3.10", | |
| "commands": [ | |
| "mv ./options/locale/locale_en-US.ini ./options/", | |
| "sed -i -e 's/=\"/=/g' -e 's/\"$$//g' ./options/locale/*.ini", | |
| "sed -i -e 's/\\\\\\\\\"/\"/g' ./options/locale/*.ini", | |
| "mv ./options/locale_en-US.ini ./options/locale/" | |
| ], | |
| "when": { | |
| "event": [ "push" ], | |
| "branch": [ "master" ] | |
| } | |
| }, | |
| { | |
| "name": "git_push", | |
| "image": "appleboy/drone-git-push", | |
| "pull": "always", | |
| "settings": { | |
| "key": { | |
| "from_secret": "git_push_ssh_key" | |
| }, | |
| "remote": "git@github.com:go-gitea/gitea.git", | |
| "force": false, | |
| "commit": true, | |
| "commit_message": "[skip ci] Updated translations via Crowdin", | |
| "author_name": "GiteaBot", | |
| "author_email": "teabot@gitea.io" | |
| }, | |
| "when": { | |
| "event": [ "push" ], | |
| "branch": [ "master" ] | |
| } | |
| }, | |
| build("pre-build", "webhippie/nodejs:latest", "", "make css;make js"), | |
| build("build-without-gcc", golang, "", "go build -o gitea_no_gcc"), | |
| build("build", golang, "TAGS:bindata sqlite sqlite_unlock_notify", "make clean;make generate;make golangci-lint;make revive;make swagger-check;make swagger-validate;make test-vendor;make build"), | |
| test("unit-test", "TAGS:bindata sqlite sqlite_unlock_notify", "make unit-test-coverage", "push;pull_request", "master"), | |
| test("release-test", "TAGS:bindata sqlite sqlite_unlock_notify", "make test", "push;pull_request", "release/*"), | |
| test("tag-test", "TAGS:bindata", "make test", "tag", ""), | |
| test("test-sqlite", "TAGS:bindata", "sql", "push;tag;pull_request", ""), | |
| test("test-mysql", "TAGS:bindata;TEST_LDAP:1", "sql1", "push;pull_request", "master"), | |
| test("tag-test-mysql", "TAGS:bindata;TEST_LDAP:1", "sql", "tag", ""), | |
| test("test-mysql8", "TAGS:bindata;TEST_LDAP:1", "sql", "push;tag;pull_request", ""), | |
| test("test-pgsql", "TAGS:bindata;TEST_LDAP:1", "sql", "push;tag;pull_request", ""), | |
| test("test-mssql", "TAGS:bindata;TEST_LDAP:1", "sql", "push;tag;pull_request", ""), | |
| // bench("bench-sqlite"), | |
| // bench("bench-mysql"), | |
| // bench("bench-mssql"), | |
| // bench("bench-pgsql"), | |
| { | |
| "name": "generate-coverage", | |
| "image": golang, | |
| "pull": "always", | |
| "environment": { | |
| "TAGS": "bindata" | |
| }, | |
| "commands": [ | |
| "make coverage" | |
| ], | |
| "when": { | |
| "event": [ "push", "pull_request" ], | |
| "branch": [ "master" ] | |
| } | |
| }, | |
| { | |
| "name": "coverage", | |
| "image": "robertstettner/drone-codecov", | |
| "settings": { | |
| "token": { | |
| "from_secret": "codecov_token" | |
| }, | |
| "files": [ | |
| "coverage.all" | |
| ], | |
| }, | |
| "when": { | |
| "event": [ "push", "pull_request" ], | |
| "branch": [ "master" ] | |
| } | |
| }, | |
| { | |
| "name": "static", | |
| "image": "techknowlogick/xgo:latest", | |
| "pull": "always", | |
| "environment": { | |
| "TAGS": "bindata sqlite sqlite_unlock_notify" | |
| }, | |
| "commands": [ | |
| "export PATH=$PATH:$GOPATH/bin", | |
| "make release" | |
| ], | |
| "when": { | |
| "event": [ "push", "tag" ] | |
| } | |
| }, | |
| { | |
| "name": "build-docs", | |
| "image": "webhippie/hugo:latest", | |
| "pull": "always", | |
| "commands": [ | |
| "cd docs", | |
| "make trans-copy", | |
| "make clean", | |
| "make build" | |
| ] | |
| }, | |
| { | |
| "name": "publish-docs", | |
| "image": "lucap/drone-netlify:latest", | |
| "pull": "always", | |
| "settings": { | |
| "netlify_token": { | |
| "from_secret": "netlify_token" | |
| }, | |
| "site_id": "d2260bae-7861-4c02-8646-8f6440b12672", | |
| "path": "docs/public/" | |
| }, | |
| "when": { | |
| "event": [ "push" ], | |
| "branch": [ "master" ] | |
| } | |
| }, | |
| docker("docker-dryrun", false, "", true, false, "pull_request", ""), | |
| docker("release-docker", true, "${DRONE_BRANCH##release/v}", false, false, "push", "release/*"), | |
| docker("docker", true, "", false, true, "push;tag", ""), | |
| { | |
| "name": "gpg-sign", | |
| "image": "plugins/gpgsign:1", | |
| "pull": "always", | |
| "settings": { | |
| "key": { | |
| "from_secret": "gpgsign_key" | |
| }, | |
| "passphrase": { | |
| "from_secret": "gpgsign_passphrase" | |
| }, | |
| "detach_sign": true, | |
| "files": [ "dist/release/*" ], | |
| "excludes": [ "dist/release/*.sha256" ] | |
| }, | |
| "when": { | |
| "event": [ "push", "tag" ] | |
| } | |
| }, | |
| s3("tag-release", "releases", "/gitea/${DRONE_TAG##v}", "tag", ""), | |
| s3("release-branch-release", "releases", "/gitea/${DRONE_BRANCH##release/v}", "push", "release/*"), | |
| s3("release", "", "/gitea/master", "push", "master"), | |
| { | |
| "name": "github", | |
| "image": "plugins/github-release:1", | |
| "pull": "always", | |
| "settings": { | |
| "api_key": { | |
| "from_secret": "github_token" | |
| }, | |
| "files": [ "dist/release/*" ] | |
| }, | |
| "when": { | |
| "event": [ "tag" ] | |
| } | |
| }, | |
| crowdin("upload_translations", "up", "locale_en-US.ini: options/locale/locale_en-US.ini"), | |
| { | |
| "name": "discord", | |
| "image": "appleboy/drone-discord:1.0.0", | |
| "pull": "always", | |
| "settings": { | |
| "webhook_id": { | |
| "from_secret": "discord_webhook_id" | |
| }, | |
| "webhook_token": { | |
| "from_secret": "discord_webhook_token" | |
| } | |
| }, | |
| "when": { | |
| "event": [ "push", "tag", "pull_request" ], | |
| "status": [ "changed", "failure" ] | |
| } | |
| } | |
| ], | |
| "services": [ | |
| service("mysql", "mysql:5.7", "MYSQL_ALLOW_EMPTY_PASSWORD:yes;MYSQL_DATABASE:test"), | |
| service("mysql8", "mysql:8.0", "MYSQL_ALLOW_EMPTY_PASSWORD:yes;MYSQL_DATABASE:testgitea"), | |
| service("pgsql", "postgres:9.5", "POSTGRES_DB:test"), | |
| service("mssql", "microsoft/mssql-server-linux:latest", "ACCEPT_EULA:Y;MSSQL_PID:Standard;SA_PASSWORD:MwantsaSecurePassword1"), | |
| service("ldap", "gitea/test-openldap:latest", ""), | |
| ] | |
| }; | |
| [ | |
| pipeline("amd64", "linux"), | |
| pipeline("arm64", "linux"), | |
| pipeline("arm", "linux"), | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment