|
| 1 | +local |
| 2 | + volume_cached_poetry = 'cached-poetry', |
| 3 | + volume_cached_deps = 'cached-deps', |
| 4 | + |
| 5 | + git_step = { |
| 6 | + name: 'fetch', |
| 7 | + image: 'docker:git', |
| 8 | + commands: ['git fetch --tags'], |
| 9 | + }, |
| 10 | + py_step(name, commands, version='3.7') = { |
| 11 | + name: name, |
| 12 | + pull: 'always', |
| 13 | + image: 'python:%s' % version, |
| 14 | + commands: commands, |
| 15 | + volumes: [ |
| 16 | + { |
| 17 | + name: volume_cached_poetry, |
| 18 | + path: '/root/.poetry', |
| 19 | + }, |
| 20 | + { |
| 21 | + name: volume_cached_deps, |
| 22 | + path: '/root/.cache/pypoetry/virtualenvs', |
| 23 | + }, |
| 24 | + ], |
| 25 | + }, |
| 26 | + notify_step(name, message) = { |
| 27 | + name: name, |
| 28 | + pull: 'always', |
| 29 | + image: 'appleboy/drone-telegram', |
| 30 | + environment: { |
| 31 | + PLUGIN_TOKEN: { |
| 32 | + from_secret: 'TELEGRAM_BOT_TOKEN', |
| 33 | + }, |
| 34 | + PLUGIN_TO: { |
| 35 | + from_secret: 'TELEGRAM_CHAT_ID', |
| 36 | + }, |
| 37 | + PLUGIN_MESSAGE: message, |
| 38 | + }, |
| 39 | + }; |
| 40 | + |
| 41 | +{ |
| 42 | + kind: 'pipeline', |
| 43 | + name: 'default', |
| 44 | + clone: { |
| 45 | + depth: 50, |
| 46 | + }, |
| 47 | + services: [ |
| 48 | + { |
| 49 | + name: 'nats', |
| 50 | + image: 'nats', |
| 51 | + pull: 'always', |
| 52 | + }, |
| 53 | + ], |
| 54 | + steps: [ |
| 55 | + git_step, |
| 56 | + py_step('deps-3.6', ['make install'], version='3.6'), |
| 57 | + py_step('deps-3.7', ['make install']), |
| 58 | + py_step('lint-3.7', ['make lint']), |
| 59 | + py_step('test-3.6', ['make test'], version='3.6') { |
| 60 | + environment: { |
| 61 | + NATS_URL: 'nats://nats:4222', |
| 62 | + }, |
| 63 | + }, |
| 64 | + py_step('test-3.7', ['make test', 'make codecov']) { |
| 65 | + environment: { |
| 66 | + NATS_URL: 'nats://nats:4222', |
| 67 | + CODECOV_TOKEN: { |
| 68 | + from_secret: 'CODECOV_TOKEN', |
| 69 | + }, |
| 70 | + }, |
| 71 | + }, |
| 72 | + notify_step('lint/test completed', ||| |
| 73 | + {{#success build.status}} |
| 74 | + `{{repo.name}}` build {{build.number}} succeeded. Good job. |
| 75 | + {{else}} |
| 76 | + `{{repo.name}}` build {{build.number}} failed. Fix me please. |
| 77 | + {{/success}} |
| 78 | + |||) { |
| 79 | + when: { |
| 80 | + branch: ['master'], |
| 81 | + event: { |
| 82 | + exclude: |
| 83 | + ['pull_request'], |
| 84 | + }, |
| 85 | + status: [ |
| 86 | + 'success', |
| 87 | + 'failure', |
| 88 | + ], |
| 89 | + }, |
| 90 | + }, |
| 91 | + py_step('publish', ['make publish']) { |
| 92 | + environment: { |
| 93 | + PYPI_USERNAME: { |
| 94 | + from_secret: 'PYPI_USERNAME', |
| 95 | + }, |
| 96 | + PYPI_PASSWORD: { |
| 97 | + from_secret: 'PYPI_PASSWORD', |
| 98 | + }, |
| 99 | + }, |
| 100 | + when: { |
| 101 | + event: ['tag'], |
| 102 | + }, |
| 103 | + }, |
| 104 | + notify_step('publish completed', ||| |
| 105 | + {{#success build.status}} |
| 106 | + `{{repo.name}}` publish {{build.tag}} succeeded. Good job. |
| 107 | + {{else}} |
| 108 | + `{{repo.name}}` publish {{build.tag}} failed. Fix me please. |
| 109 | + {{/success}} |
| 110 | + |||) { |
| 111 | + when: { |
| 112 | + event: ['tag'], |
| 113 | + status: [ |
| 114 | + 'success', |
| 115 | + 'failure', |
| 116 | + ], |
| 117 | + }, |
| 118 | + }, |
| 119 | + ], |
| 120 | + volumes: [ |
| 121 | + { |
| 122 | + name: volume_cached_poetry, |
| 123 | + temp: {}, |
| 124 | + }, |
| 125 | + { |
| 126 | + name: volume_cached_deps, |
| 127 | + temp: {}, |
| 128 | + }, |
| 129 | + ], |
| 130 | +} |
0 commit comments