dpl 1.10.17.travis.6637.6 → 2.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +74 -0
- data/CONTRIBUTING.md +392 -0
- data/Gemfile +17 -3
- data/Gemfile.lock +373 -0
- data/LICENSE +16 -19
- data/NOTES.md +275 -0
- data/README.md +1977 -707
- data/Rakefile +2 -2
- data/bin/dpl +7 -3
- data/lib/dpl.rb +20 -0
- data/lib/dpl/assets/atlas/install +19 -0
- data/lib/dpl/assets/dpl/README.erb.md +133 -0
- data/lib/dpl/assets/dpl/git_ssh +2 -0
- data/lib/dpl/assets/git/detect_private_key +8 -0
- data/lib/dpl/assets/hephy/filter_log +3 -0
- data/lib/dpl/assets/pypi/install +4 -0
- data/lib/dpl/assets/scalingo/install +6 -0
- data/lib/dpl/cli.rb +36 -48
- data/lib/dpl/ctx.rb +2 -0
- data/lib/dpl/ctx/bash.rb +543 -0
- data/lib/dpl/ctx/test.rb +242 -0
- data/lib/dpl/helper/assets.rb +36 -0
- data/lib/dpl/helper/cmd.rb +167 -0
- data/lib/dpl/helper/config_file.rb +47 -0
- data/lib/dpl/helper/env.rb +39 -0
- data/lib/dpl/helper/interpolate.rb +126 -0
- data/lib/dpl/helper/memoize.rb +20 -0
- data/lib/dpl/helper/squiggle.rb +22 -0
- data/lib/dpl/helper/zip.rb +69 -0
- data/lib/dpl/provider.rb +562 -234
- data/lib/dpl/provider/dsl.rb +369 -0
- data/lib/dpl/provider/examples.rb +128 -0
- data/lib/dpl/provider/status.rb +59 -0
- data/lib/dpl/providers.rb +40 -0
- data/lib/dpl/providers/anynines.rb +65 -0
- data/lib/dpl/providers/atlas.rb +49 -0
- data/lib/dpl/providers/azure_web_apps.rb +59 -0
- data/lib/dpl/providers/bintray.rb +313 -0
- data/lib/dpl/providers/bluemixcloudfoundry.rb +92 -0
- data/lib/dpl/providers/boxfuse.rb +48 -0
- data/lib/dpl/providers/cargo.rb +19 -0
- data/lib/dpl/providers/chef_supermarket.rb +128 -0
- data/lib/dpl/providers/cloud66.rb +40 -0
- data/lib/dpl/providers/cloudfiles.rb +56 -0
- data/lib/dpl/providers/cloudfoundry.rb +81 -0
- data/lib/dpl/providers/codedeploy.rb +179 -0
- data/lib/dpl/providers/datica.rb +60 -0
- data/lib/dpl/providers/elasticbeanstalk.rb +195 -0
- data/lib/dpl/providers/engineyard.rb +107 -0
- data/lib/dpl/providers/firebase.rb +41 -0
- data/lib/dpl/providers/gae.rb +74 -0
- data/lib/dpl/providers/gcs.rb +105 -0
- data/lib/dpl/providers/hackage.rb +47 -0
- data/lib/dpl/providers/hephy.rb +101 -0
- data/lib/dpl/providers/heroku.rb +111 -0
- data/lib/dpl/providers/heroku/api.rb +119 -0
- data/lib/dpl/providers/heroku/git.rb +50 -0
- data/lib/dpl/providers/lambda.rb +202 -0
- data/lib/dpl/providers/launchpad.rb +74 -0
- data/lib/dpl/providers/netlify.rb +30 -0
- data/lib/dpl/providers/npm.rb +88 -0
- data/lib/dpl/providers/openshift.rb +46 -0
- data/lib/dpl/providers/opsworks.rb +142 -0
- data/lib/dpl/providers/packagecloud.rb +190 -0
- data/lib/dpl/providers/pages.rb +17 -0
- data/lib/dpl/providers/pages/api.rb +102 -0
- data/lib/dpl/providers/pages/git.rb +251 -0
- data/lib/dpl/providers/puppetforge.rb +44 -0
- data/lib/dpl/providers/pypi.rb +120 -0
- data/lib/dpl/providers/releases.rb +214 -0
- data/lib/dpl/providers/rubygems.rb +89 -0
- data/lib/dpl/providers/s3.rb +243 -0
- data/lib/dpl/providers/scalingo.rb +63 -0
- data/lib/dpl/providers/script.rb +28 -0
- data/lib/dpl/providers/snap.rb +59 -0
- data/lib/dpl/providers/surge.rb +55 -0
- data/lib/dpl/providers/testfairy.rb +93 -0
- data/lib/dpl/providers/transifex.rb +66 -0
- data/lib/dpl/support/aws_sdk_patch.rb +23 -0
- data/lib/dpl/support/gems.rb +69 -0
- data/lib/dpl/support/gstore_patch.rb +6 -0
- data/lib/dpl/support/version.rb +83 -0
- data/lib/dpl/version.rb +2 -2
- metadata +98 -169
- data/.coveralls.yml +0 -1
- data/.github/CONTRIBUTING.md +0 -173
- data/.github/stale.yml +0 -53
- data/.gitignore +0 -13
- data/.rspec +0 -2
- data/.travis.yml +0 -56
- data/dpl-anynines.gemspec +0 -3
- data/dpl-atlas.gemspec +0 -3
- data/dpl-azure_webapps.gemspec +0 -3
- data/dpl-bintray.gemspec +0 -3
- data/dpl-bitballoon.gemspec +0 -3
- data/dpl-bluemix_cloud_foundry.gemspec +0 -3
- data/dpl-boxfuse.gemspec +0 -3
- data/dpl-cargo.gemspec +0 -3
- data/dpl-catalyze.gemspec +0 -3
- data/dpl-chef_supermarket.gemspec +0 -20
- data/dpl-cloud66.gemspec +0 -3
- data/dpl-cloud_files.gemspec +0 -3
- data/dpl-cloud_foundry.gemspec +0 -3
- data/dpl-code_deploy.gemspec +0 -3
- data/dpl-deis.gemspec +0 -3
- data/dpl-elastic_beanstalk.gemspec +0 -3
- data/dpl-engine_yard.gemspec +0 -3
- data/dpl-firebase.gemspec +0 -3
- data/dpl-gae.gemspec +0 -3
- data/dpl-gcs.gemspec +0 -3
- data/dpl-hackage.gemspec +0 -3
- data/dpl-hephy.gemspec +0 -3
- data/dpl-heroku.gemspec +0 -3
- data/dpl-lambda.gemspec +0 -3
- data/dpl-launchpad.gemspec +0 -3
- data/dpl-npm.gemspec +0 -3
- data/dpl-openshift.gemspec +0 -3
- data/dpl-ops_works.gemspec +0 -3
- data/dpl-packagecloud.gemspec +0 -3
- data/dpl-pages.gemspec +0 -3
- data/dpl-puppet_forge.gemspec +0 -3
- data/dpl-pypi.gemspec +0 -3
- data/dpl-releases.gemspec +0 -8
- data/dpl-rubygems.gemspec +0 -3
- data/dpl-s3.gemspec +0 -3
- data/dpl-scalingo.gemspec +0 -3
- data/dpl-script.gemspec +0 -3
- data/dpl-snap.gemspec +0 -3
- data/dpl-surge.gemspec +0 -3
- data/dpl-testfairy.gemspec +0 -3
- data/dpl-transifex.gemspec +0 -3
- data/dpl.gemspec +0 -3
- data/gemspec_helper.rb +0 -51
- data/lib/dpl/error.rb +0 -3
- data/notes/engine_yard.md +0 -1
- data/notes/heroku.md +0 -3
- data/spec/cli_spec.rb +0 -36
- data/spec/provider_spec.rb +0 -191
- data/spec/spec_helper.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 519a5f3a45594b98b9cea78a174915cb82e8ed49
|
|
4
|
+
data.tar.gz: '04381cd09207b9b35e2e0c4ff01a266eb198cc90'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13c81c90f3bebfe9d92f9617b0360fac5d37cb74cc6d8ced73dc0f41a07ab4b5805164e5eb0189b4833029b758555906b81b4702e61beadaec8f8526c03fe77b
|
|
7
|
+
data.tar.gz: 15a8ecbd8a12c78cfffba74f0e3dad2757051beba9f8d0b26bd7001b58b856b6ff536028677257e4d19b446dfa7e775f9ca5ada924a03fdc9daf01eed827fdce
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## dpl v2.0.0-alpha.1 (eta 2019-08-28)
|
|
4
|
+
|
|
5
|
+
* Default to not cleaning the git working directory, but accept `--cleanup` in order to clean up the git working directory.
|
|
6
|
+
* Support a maturity model using dev, alpha, beta, stable.
|
|
7
|
+
* Use Ruby's `DidYouMean` in order to suggest provider names if the given name is not valid.
|
|
8
|
+
* Use `~/.dpl` rather than `./.dpl` as a directory to store assets, and remove `~/.dpl` before the process terminates.
|
|
9
|
+
* Use the AWS SDK v3 for AWS providers.
|
|
10
|
+
* Fix git-ssh to work with non-standard ssh ports (used by all providers that rely on Git).
|
|
11
|
+
|
|
12
|
+
### bintray
|
|
13
|
+
* List files in the downloads list if specified in the descriptor file.
|
|
14
|
+
|
|
15
|
+
### chef-supermarket
|
|
16
|
+
* Read the cookbook name a given metadata.json or metadata.rb file if not given as `--name`.
|
|
17
|
+
* Use `--name` and `--category`, but keep `--cookbook_name` and `--cookbook_category` as deprecated aliases.
|
|
18
|
+
|
|
19
|
+
### cloudfoundry
|
|
20
|
+
* Accept `--v3` in order to use the `v3-push` command.
|
|
21
|
+
|
|
22
|
+
### codedeploy
|
|
23
|
+
* Accept `--file_exist_behavior` in order to specify how to handle files that already exist in a deployment target location.
|
|
24
|
+
|
|
25
|
+
### elasticbeanstalk
|
|
26
|
+
* Accept `--label` and `--description` in order to define these attributes.
|
|
27
|
+
* Remove non-printable unicode chars from the version description.
|
|
28
|
+
* Accept `--debug` in order to list files added to the zip archive.
|
|
29
|
+
* Honor `.ebignore` in order to exclude files from being added to the zip file.
|
|
30
|
+
|
|
31
|
+
### engineyard
|
|
32
|
+
* Use `ey-core` as CLI tooling.
|
|
33
|
+
|
|
34
|
+
### firebase
|
|
35
|
+
* Accept `--only` in order to restrict the resources to deploy.
|
|
36
|
+
* Accpet `--force` in order to delete functions missing from the current working directory.
|
|
37
|
+
* Add `node_modules/.bin` to the `PATH` in case users have `firebase` in that directory.
|
|
38
|
+
|
|
39
|
+
### gae
|
|
40
|
+
* Accept multiple values on on `--config`.
|
|
41
|
+
|
|
42
|
+
### hackage
|
|
43
|
+
* Accept `--publish` in order to publish a package.
|
|
44
|
+
|
|
45
|
+
### lambda
|
|
46
|
+
* Accept `--layers` to deploy function layers.
|
|
47
|
+
* Do not require a role and handler name when functions are only being updated.
|
|
48
|
+
* Use the correct handler name separators for dotnet, go, and java runtimes.
|
|
49
|
+
|
|
50
|
+
### npm
|
|
51
|
+
* Accept `--registry` in order to specify the target registry.
|
|
52
|
+
* Accept `--src` in order to specify a directory or tarball to publish.
|
|
53
|
+
* Accept `auth` as an `--auth_method` in order to force writing the token to `_auth` in `~/.npmrc`.
|
|
54
|
+
|
|
55
|
+
### pages
|
|
56
|
+
* Accept a `--deploy_key` as an alternative to the GitHub token (expects a path to a file).
|
|
57
|
+
* Accept a commit message on `--commit_message`, allow interpolating variables (e.g. as `$TRAVIS_BUILD_NUMBER`).
|
|
58
|
+
* Check if the target branch already exists and preserves git history by default. `--no-keep_history` can be passed in order to erase history on the target branch.
|
|
59
|
+
* Include symbolic links.
|
|
60
|
+
* Add an alternative strategy for deploying via GitHub's pages HTTP API
|
|
61
|
+
|
|
62
|
+
### pypi
|
|
63
|
+
* Accept `--no-remove_build_dir` in order to skip removing the build dir (`./dist`).
|
|
64
|
+
* Run `twine check dist/*` by default, and accept `--no-twine_check` for opting out.
|
|
65
|
+
|
|
66
|
+
### releases
|
|
67
|
+
* Accept a path to a file containing release notes on `--release_notes_file`.
|
|
68
|
+
* Use `--release_notes` for passing the release notes content, keep `--body` as a deprecated alias.
|
|
69
|
+
|
|
70
|
+
### s3
|
|
71
|
+
* Accept `--no-overwrite` in order to not overwrite existing files.
|
|
72
|
+
* Accept `--force_path_style` in order to use the bucket name on the path, rather than the subcomain
|
|
73
|
+
* Print out dots instead of filenames by default, and accept `--verbose` for printing out all filenames uploaded.
|
|
74
|
+
* Use `application/octet-stream` as a default content type if a content type cannot be determined.
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Contributing to Dpl
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
* [Resources](#resources)
|
|
6
|
+
* [Navigating the Codebase](#navigating-the-codebase)
|
|
7
|
+
* [Lifecycle of the Deployment Process](#lifecycle-of-the-deployment-process)
|
|
8
|
+
* [Deployment Tooling](#deployment-tooling)
|
|
9
|
+
* [Runtime Dependencies](#runtime-dependencies)
|
|
10
|
+
* [Unit Tests](#unit-tests)
|
|
11
|
+
* [Runtime Dependency Installation Tests](#runtime-dependency-installation-tests)
|
|
12
|
+
* [Integration Tests](#integration-tests)
|
|
13
|
+
* [Testing Dpl Branches or Forks on Travis CI](#testing-dpl-branches-or-forks-on-travis-ci)
|
|
14
|
+
* [Code Conventions](#code-conventions)
|
|
15
|
+
* [Naming Conventions](#naming-conventions)
|
|
16
|
+
* [Updating the README](#updating-the-readme)
|
|
17
|
+
|
|
18
|
+
Dpl is a central component in Travis CI, and has been around for a long time.
|
|
19
|
+
|
|
20
|
+
This library always has been a community effort first. There probably is not a
|
|
21
|
+
single person in the world who is very familiar with all deployment providers
|
|
22
|
+
supported by Dpl.
|
|
23
|
+
|
|
24
|
+
*Thank you all for this!*
|
|
25
|
+
|
|
26
|
+
This document is for you if you are looking to contribute to dpl, be it by
|
|
27
|
+
adding a new deployment provider, fixing a bug, or adding a new feature.
|
|
28
|
+
|
|
29
|
+
Dpl has a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all
|
|
30
|
+
interactions with the project.
|
|
31
|
+
|
|
32
|
+
Dpl is written in Ruby, and we assume that you familiarize yourself with our
|
|
33
|
+
documentation as much as needed.
|
|
34
|
+
|
|
35
|
+
## Resources
|
|
36
|
+
|
|
37
|
+
Hopefully helpful resources are:
|
|
38
|
+
|
|
39
|
+
* This [document](CONTRIBUTING.md)
|
|
40
|
+
* The [dpl README](README.md)
|
|
41
|
+
* The [dpl API docs](https://www.rubydoc.info/github/travis-ci/dpl) on rubydocs.info
|
|
42
|
+
* The [cl README](https://github.com/svenfuchs/cl/blob/master/README.md)
|
|
43
|
+
|
|
44
|
+
## Navigating the Codebase
|
|
45
|
+
|
|
46
|
+
All provider specific classes live in [dpl/providers](lib/dpl/providers).
|
|
47
|
+
These represent the CLI commands that are executed when the command line
|
|
48
|
+
exectuable `dpl` is run with a given provider name as the first argument.
|
|
49
|
+
|
|
50
|
+
Each provider is a subclass of `Dpl::Provider`, which is defined in
|
|
51
|
+
[dpl/provider.rb](lib/dpl/provider.rb). The provider base class itself
|
|
52
|
+
subclasses from `Cl::Cmd`, so it represents an executable sub command of the
|
|
53
|
+
main command `dpl`.
|
|
54
|
+
|
|
55
|
+
For instance, the command `dpl s3 --bucket bucket` instantiates and runs the
|
|
56
|
+
provider class [S3](lib/dpl/providers/s3.rb).
|
|
57
|
+
|
|
58
|
+
The class `Cl::Cmd` contributes the command line options parser, and its
|
|
59
|
+
class level DSL. Please see the [cl README](https://github.com/svenfuchs/cl/blob/master/README.md)
|
|
60
|
+
for this DSL, and the [S3 provider](/lib/dpl/provider/s3.rb)
|
|
61
|
+
for an example how dpl uses it.
|
|
62
|
+
|
|
63
|
+
The class `Dpl::Provider` adds, amongst other things, the order of stages
|
|
64
|
+
(methods) that make up the deployment process:
|
|
65
|
+
|
|
66
|
+
* `init`
|
|
67
|
+
* `install`
|
|
68
|
+
* `login`
|
|
69
|
+
* `setup`
|
|
70
|
+
* `validate`
|
|
71
|
+
* `prepare`
|
|
72
|
+
* `deploy`
|
|
73
|
+
* `finish`
|
|
74
|
+
|
|
75
|
+
Implementors of concrete provider classes may or may not choose to implement
|
|
76
|
+
any of these instance methods according to their needs, and semantics of their
|
|
77
|
+
tooling and service providers. Please refer to [Dpl::Provider](/lib/dpl/provider.rb)
|
|
78
|
+
for details.
|
|
79
|
+
|
|
80
|
+
The DSL that is used to declare features, dependencies, environment integration
|
|
81
|
+
etc. on the concrete provider classes is defined in the module
|
|
82
|
+
`Dpl::Provider::DSL`, in [dpl/provider/dsl](/lib/dpl/provider/dsl.rb).
|
|
83
|
+
|
|
84
|
+
Also of interest is [Dpl::Ctx::Bash](/lib/dpl/ctx/bash.rb),
|
|
85
|
+
the Bash execution context, that runs shell commands, installs dependencies
|
|
86
|
+
etc. (while the `Test` context class is used for testing in order to keep your
|
|
87
|
+
development machine clean and safe when you run tests locally).
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
lib
|
|
91
|
+
└── dpl
|
|
92
|
+
├── assets # Stores larger shell scripts
|
|
93
|
+
├── ctx
|
|
94
|
+
│ ├── bash.rb # Bash execution context
|
|
95
|
+
│ └── test.rb # Test execution context
|
|
96
|
+
├── provider.rb # Base class for all providers
|
|
97
|
+
├── provider
|
|
98
|
+
│ ├── dsl.rb # DSL for defining providers
|
|
99
|
+
│ └── example.rb # Generating example commands for help output
|
|
100
|
+
└── providers
|
|
101
|
+
├── anynines.rb # Concrete providers
|
|
102
|
+
├── atlas.rb
|
|
103
|
+
├── azure_webapps.rb
|
|
104
|
+
├── bintray.rb
|
|
105
|
+
├── bitballoon.rb
|
|
106
|
+
└── ⋮
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Lifecycle of the Deployment Process
|
|
110
|
+
|
|
111
|
+
When a provider class is instantiated and run it will go through a number
|
|
112
|
+
of stages that make up the deployment process.
|
|
113
|
+
|
|
114
|
+
These are documented in [dpl/provider.rb](/lib/dpl/provider.rb).
|
|
115
|
+
If you are adding a new deployment provider please familiarize youself with
|
|
116
|
+
this lifecycle.
|
|
117
|
+
|
|
118
|
+
Feel free to pick and interpret these stages according to the needs and
|
|
119
|
+
semantics of the service provider you are adding. By no means do all of these
|
|
120
|
+
stages have to be filled in or implmented. The `Provider` base class checks for
|
|
121
|
+
these methods, and runs them, if present, so that implementors can choose
|
|
122
|
+
semantically fitting names for their providers.
|
|
123
|
+
|
|
124
|
+
## Deployment Tooling
|
|
125
|
+
|
|
126
|
+
If you are adding a new deployment provider please choose the tooling you are
|
|
127
|
+
going to use carefully.
|
|
128
|
+
|
|
129
|
+
Dpl is a long lived library, and it has outlived many tools that once were
|
|
130
|
+
supported, and no longer are. Thus tooling stability is a major concern for
|
|
131
|
+
this project.
|
|
132
|
+
|
|
133
|
+
Ideally use official CLI tooling supported by the company who's service
|
|
134
|
+
provider you are about to add. Often, such CLI tools can be installed via
|
|
135
|
+
standard package managers, or manually downloaded using `curl` and installed
|
|
136
|
+
with a few simple Bash commands.
|
|
137
|
+
|
|
138
|
+
Such CLI tooling is preferrable over Ruby gem runtime dependencies as they can
|
|
139
|
+
be executed in a child process, and won't introduce any dependency resolution
|
|
140
|
+
problems later on.
|
|
141
|
+
|
|
142
|
+
If no such CLI is available, or it does not look well supported, and your
|
|
143
|
+
provider implementation needs to talk to an external HTTP API then please consider
|
|
144
|
+
using [Net::HTTP](https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html)
|
|
145
|
+
from Ruby's standard library.
|
|
146
|
+
|
|
147
|
+
If you absolutely have to rely on a runtime Ruby gem dependency, such as a
|
|
148
|
+
provider client implementation, please only do so if the gem is supported by
|
|
149
|
+
the respective company officially. We may choose to reject including runtime
|
|
150
|
+
dependencies that do not look stable or widely supported.
|
|
151
|
+
|
|
152
|
+
## Runtime Dependencies
|
|
153
|
+
|
|
154
|
+
Runtime dependencies can be declared on the provider class using the
|
|
155
|
+
[DSL](lib/dpl/provider/dsl.rb).
|
|
156
|
+
|
|
157
|
+
In the case of APT, NPM, and Pip dependencies these will be installed via
|
|
158
|
+
shell commands at the beginning of the deployment process.
|
|
159
|
+
|
|
160
|
+
Ruby gem dependencies will be installed using Bundler's [inline API](https://github.com/bundler/bundler/blob/master/lib/bundler/inline.rb),
|
|
161
|
+
at the beginning of the deployment process, so they are available in the same
|
|
162
|
+
Ruby process from then on.
|
|
163
|
+
|
|
164
|
+
## Unit Tests
|
|
165
|
+
|
|
166
|
+
`Dpl` uses [RSpec](https://github.com/rspec) for tests. The specs reside in
|
|
167
|
+
`spec`, and each provider class has a corresponding file
|
|
168
|
+
`spec/dpl/providers/*_spec.rb` to hold tests.
|
|
169
|
+
|
|
170
|
+
Provider tests should be implemented on an input/output acceptance level, as
|
|
171
|
+
much as possible.
|
|
172
|
+
|
|
173
|
+
They use a [Ctx::Test](blob/masterlib/dpl/ctx/test.rb) execution context in
|
|
174
|
+
order to avoid running actual shell commands, or actually installing
|
|
175
|
+
dependencies at test time. There are custom [RSpec matchers](spec/support/matchers)
|
|
176
|
+
in place that help with making assertions against this execution context.
|
|
177
|
+
|
|
178
|
+
If your provider has to talk to an external HTTP API then ideally use
|
|
179
|
+
[Webmock](https://github.com/bblimke/webmock) to stub external requests. If by
|
|
180
|
+
any means possible try to avoid mocking or stubbing Ruby client classes (this
|
|
181
|
+
is not always possible, but should be considered).
|
|
182
|
+
|
|
183
|
+
### Running Unit Tests Locally
|
|
184
|
+
|
|
185
|
+
You can run the unit test suite locally as follows:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
bundle install
|
|
189
|
+
bundle exec rspec
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
In order to execute tests only for a certain provider you can run:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
bundle exec rspec spec/dpl/providers/[provider]_spec.rb
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
In order to execute a single test or group of tests add a line number like so:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
bundle exec rspec spec/dpl/providers/[provider]_spec.rb:25
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
These tests can be run safely on any development machine, anywhere.
|
|
205
|
+
|
|
206
|
+
## Runtime Dependency Installation Tests
|
|
207
|
+
|
|
208
|
+
We additionally run tests that exercise runtime dependency installation on
|
|
209
|
+
Travis CI.
|
|
210
|
+
|
|
211
|
+
These live in [.travis/test_install.rb](.travis/test_install.rb). It is not
|
|
212
|
+
advisable to run these tests outside of an ephemeral VM or container that can
|
|
213
|
+
be safely discarded, as they are going to leave various artifacts around.
|
|
214
|
+
|
|
215
|
+
## Integration Tests
|
|
216
|
+
|
|
217
|
+
In order to ensure proper integration with the service providers supported
|
|
218
|
+
we also periodically run a test suite that exercises actual deployments to
|
|
219
|
+
these providers.
|
|
220
|
+
|
|
221
|
+
These tests live in [.travis/providers](/.travis/providers), and the are
|
|
222
|
+
triggered using the script [trigger](/.travis/trigger).
|
|
223
|
+
|
|
224
|
+
An integration test consists of:
|
|
225
|
+
|
|
226
|
+
* A setup script that creates an application (or artifact) to deploy (or
|
|
227
|
+
upload).
|
|
228
|
+
* A YAML config snippet that configures and triggers the deployment as part of
|
|
229
|
+
a build on Travis CI.
|
|
230
|
+
* A test script that tests if the deployment was successful.
|
|
231
|
+
|
|
232
|
+
For example:
|
|
233
|
+
|
|
234
|
+
* [github-pages/prepare](/.travis/providers/github-pages/prepare)
|
|
235
|
+
creates a minimal Git repository that serves an `index.html` on GitHub Pages in a temporary directory.
|
|
236
|
+
* [github-pages/travis.yml](/.travis/providers/github-pages/travis.yml)
|
|
237
|
+
configures the build to use Dpl 2.0 to deploy this repository to GitHub Pages.
|
|
238
|
+
* [github-pages/test](/.travis/providers/github-pages/test)
|
|
239
|
+
tests if the deployment was successful.
|
|
240
|
+
|
|
241
|
+
The tests can be run on Travis CI individually, or combined, by triggering a
|
|
242
|
+
build via our API, using the script [.travis/trigger](/.travis/trigger).
|
|
243
|
+
This takes a provider name as an argument, and requires a Travis CI API token.
|
|
244
|
+
|
|
245
|
+
For example, this triggers a build that executes the GitHub Pages test on
|
|
246
|
+
Travis CI:
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
.travis/trigger github-pages --token [token]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The token can also be set as an environment variable:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
export TRAVIS_API_TOKEN=[token]
|
|
256
|
+
.travis/trigger github-pages
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The `trigger` script accepts multiple provider names as arguments. If no
|
|
260
|
+
arguments are given then tests for all providers will be run.
|
|
261
|
+
|
|
262
|
+
### Integration Test Configuration
|
|
263
|
+
|
|
264
|
+
In the build config YAML snippet make sure to use the branch of your fork for the
|
|
265
|
+
deployment tooling, and allow the deployment to run on your branch:
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
deploy:
|
|
269
|
+
- provider: [name]
|
|
270
|
+
edge:
|
|
271
|
+
source: [your-login]/dpl
|
|
272
|
+
branch: [your-branch]
|
|
273
|
+
on:
|
|
274
|
+
branch: [your-branch]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Ideally use credentials for an isolated account on the service you are deploying to.
|
|
278
|
+
This is generally good practice, and way you can hand things off to someone else.
|
|
279
|
+
|
|
280
|
+
In order to get things working encrypt the credentials against your fork, and
|
|
281
|
+
add them to the build config YAML snippet. If you are in the root directory
|
|
282
|
+
of your fork then this command should do the trick:
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
travis encrypt password=[password]
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
If you do not have the `travis` CLI installed you can install it using:
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
gem install travis
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
When you add encrypted credentials to the build config YAML snippet also add a comment
|
|
295
|
+
that allows others to identify the account used. E.g:
|
|
296
|
+
|
|
297
|
+
```yaml
|
|
298
|
+
deploy:
|
|
299
|
+
- provider: pages
|
|
300
|
+
github_token:
|
|
301
|
+
# personal access token with repo scope on the account [name]
|
|
302
|
+
secure: "[encrypted token]"
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Open a pull request. In order for us to merge your test, and get it working on
|
|
306
|
+
our repository you will need to re-encrypt the credentials against
|
|
307
|
+
`travis-ci/dpl`, like so:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
travis encrypt -r travis-ci/dpl password=[password]
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Whatever minimal deployment you can get working is be a great contribution.
|
|
314
|
+
Even if for some reason it proves hard to test the deployment in an automated
|
|
315
|
+
fashion, but you have a successful deployment that can be verified manually,
|
|
316
|
+
please still open a pull request, and talk to us. Any test is better than no
|
|
317
|
+
test.
|
|
318
|
+
|
|
319
|
+
## Testing Dpl Branches or Forks on Travis CI
|
|
320
|
+
|
|
321
|
+
It is possible to test a new deployment provider or new functionality of dpl on
|
|
322
|
+
Travis CI. In order to do so, add proper configuraiton on the `edge` key to
|
|
323
|
+
your `.travis.yml` like so:
|
|
324
|
+
|
|
325
|
+
```yaml
|
|
326
|
+
deploy:
|
|
327
|
+
provider: [name]
|
|
328
|
+
edge:
|
|
329
|
+
source: [github-handle]/dpl
|
|
330
|
+
branch: [branch]
|
|
331
|
+
on:
|
|
332
|
+
branch: TEST_BRANCH # or all_branches: true
|
|
333
|
+
⋮ # rest of your provider's configuration
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
This builds the `dpl` gem on the Travis CI build environment from your
|
|
337
|
+
repository, on the given branch. Then it installs the gem built from this code
|
|
338
|
+
base, and uses it to run your deployment.
|
|
339
|
+
|
|
340
|
+
When submitting a pull request, please be sure to run at least one deployment
|
|
341
|
+
with the new configuration, and provide a link to the build in your pull
|
|
342
|
+
request.
|
|
343
|
+
|
|
344
|
+
## Code Conventions
|
|
345
|
+
|
|
346
|
+
Dpl does not follow any strict code styleguide.
|
|
347
|
+
|
|
348
|
+
Please take a look around other providers, and try to follow a similar code
|
|
349
|
+
style to what you find.
|
|
350
|
+
|
|
351
|
+
Try to use the [DSL](/lib/dpl/provider/dsl.rb) as much
|
|
352
|
+
as possible. It keeps the code declarative and readable, so that people not
|
|
353
|
+
familiar with Ruby or programming in general can still follow it, and make
|
|
354
|
+
sense of it.
|
|
355
|
+
|
|
356
|
+
If you find yourself trying to achieve something that should be, but is not
|
|
357
|
+
supported by the DSL please [open an issue](https://github.com/travis-ci/dpl/issues/new)
|
|
358
|
+
about it.
|
|
359
|
+
|
|
360
|
+
If you are rather unfamiliar with Ruby, and have trouble following our code
|
|
361
|
+
style then please submit your pull request anyway, or get in touch, so we can
|
|
362
|
+
help.
|
|
363
|
+
|
|
364
|
+
## Naming Conventions
|
|
365
|
+
|
|
366
|
+
Dpl uses constant names following Ruby naming conventions. I.e. constant
|
|
367
|
+
names use `CamelCase`, and they live in files named in `snake_case.rb`.
|
|
368
|
+
|
|
369
|
+
If you pick such names for a new provider please try to follow these
|
|
370
|
+
conventions.
|
|
371
|
+
|
|
372
|
+
Real world service provider or company names do not always translate to such
|
|
373
|
+
conventional Ruby names one-to-one. That is ok, they don't have to. These Ruby
|
|
374
|
+
constant names are representations of real world service and company names in
|
|
375
|
+
Ruby code.
|
|
376
|
+
|
|
377
|
+
Other Ruby libraries often (not always) follow a similar thinking. E.g.
|
|
378
|
+
even though Amazon Web Services brand name is `AWS` the module name
|
|
379
|
+
they chose in their [aws-sdk](https://github.com/aws/aws-sdk-ruby) is
|
|
380
|
+
`Aws`, not `AWS`.
|
|
381
|
+
|
|
382
|
+
## Updating the README
|
|
383
|
+
|
|
384
|
+
The [README](/README.md) is generated from a
|
|
385
|
+
[template](/lib/dpl/assets/dpl/README.erb.md).
|
|
386
|
+
|
|
387
|
+
In order to update the README please edit the template, and run:
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
gem install ffi-icu
|
|
391
|
+
bin/readme > README.md
|
|
392
|
+
```
|