├── .coveralls.yml ├── .github └── stale.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .travis.yml ├── .travis ├── blank.yml ├── providers │ ├── anynines │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── aws-elasticbeanstalk │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── aws-lambda │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── aws-s3 │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── azure_web_apps │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── bintray │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── bluemixcloudfoundry │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── boxfuse │ │ ├── main.go │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── cargo │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── chef_supermarket │ │ ├── delete │ │ ├── prepare │ │ ├── private_key.enc │ │ ├── test │ │ └── travis.yml │ ├── cloud66 │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── cloudfoundry │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── datica │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── engineyard │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── firebase │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── gae │ │ ├── app.yaml │ │ ├── main.go │ │ ├── prepare │ │ ├── service-account.json.enc │ │ ├── start │ │ ├── stop │ │ ├── test │ │ └── travis.yml │ ├── gcs │ │ ├── key.json.enc │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── git_push │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── github-pages │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── github-releases │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── gleis │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── hackage │ │ ├── delete │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── hephy │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── config.ru │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── heroku │ │ ├── api.yml │ │ ├── git.yml │ │ ├── prepare │ │ └── test │ ├── netlify │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── npm-github │ │ ├── prepare │ │ ├── query.graphql │ │ ├── test │ │ └── travis.yml │ ├── npm-myget │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── npm │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── nuget-myget │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── openshift │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── packagecloud │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── puppetforge │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── pypi │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── rubygems │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── scalingo │ │ ├── prepare │ │ ├── scale │ │ ├── test │ │ └── travis.yml │ ├── snap │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── surge │ │ ├── prepare │ │ ├── test │ │ └── travis.yml │ ├── testfairy │ │ ├── prepare │ │ ├── test │ │ ├── testfairy.apk │ │ └── travis.yml │ └── transifex │ │ ├── prepare │ │ ├── test │ │ └── travis.yml ├── test_install └── trigger ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── dpl ├── readme └── status ├── config └── transliterate.yml ├── dpl.gemspec ├── lib ├── dpl.rb └── dpl │ ├── assets │ ├── atlas │ │ └── install │ ├── convox │ │ └── install │ ├── dpl │ │ ├── README.erb.md │ │ └── git_ssh │ ├── git │ │ └── detect_private_key │ ├── hephy │ │ └── filter_log │ ├── pypi │ │ └── install │ └── scalingo │ │ └── install │ ├── cli.rb │ ├── ctx.rb │ ├── ctx │ ├── bash.rb │ └── test.rb │ ├── helper │ ├── assets.rb │ ├── cmd.rb │ ├── config_file.rb │ ├── cookbook_site_streaming_uploader.rb │ ├── env.rb │ ├── github.rb │ ├── interpolate.rb │ ├── memoize.rb │ ├── squiggle.rb │ ├── transliterate.rb │ ├── wrap.rb │ └── zip.rb │ ├── provider.rb │ ├── provider │ ├── dsl.rb │ ├── examples.rb │ └── status.rb │ ├── providers.rb │ ├── providers │ ├── anynines.rb │ ├── azure_web_apps.rb │ ├── bintray.rb │ ├── bluemixcloudfoundry.rb │ ├── boxfuse.rb │ ├── cargo.rb │ ├── chef_supermarket.rb │ ├── cloud66.rb │ ├── cloudfiles.rb │ ├── cloudformation.rb │ ├── cloudfoundry.rb │ ├── codedeploy.rb │ ├── convox.rb │ ├── datica.rb │ ├── ecr.rb │ ├── elasticbeanstalk.rb │ ├── engineyard.rb │ ├── firebase.rb │ ├── flynn.rb │ ├── gae.rb │ ├── gcs.rb │ ├── git_push.rb │ ├── gleis.rb │ ├── hackage.rb │ ├── hephy.rb │ ├── heroku.rb │ ├── heroku │ │ ├── api.rb │ │ └── git.rb │ ├── lambda.rb │ ├── launchpad.rb │ ├── netlify.rb │ ├── npm.rb │ ├── nuget.rb │ ├── openshift.rb │ ├── opsworks.rb │ ├── packagecloud.rb_ │ ├── pages.rb │ ├── pages │ │ ├── api.rb │ │ └── git.rb │ ├── puppetforge.rb │ ├── pypi.rb │ ├── releases.rb │ ├── rubygems.rb │ ├── s3.rb │ ├── scalingo.rb │ ├── script.rb │ ├── snap.rb │ ├── surge.rb │ ├── testfairy.rb │ └── transifex.rb │ ├── string_ext.rb │ ├── support │ ├── aws_sdk_patch.rb │ ├── gems.rb │ ├── gstore_patch.rb │ └── version.rb │ └── version.rb ├── spec ├── dpl │ ├── cli_spec.rb │ ├── ctx │ │ └── bash_spec.rb │ ├── helper │ │ ├── cmd_spec.rb │ │ ├── env_spec.rb │ │ ├── github_spec.rb │ │ ├── interpolate_spec.rb │ │ └── zip_spec.rb │ ├── provider │ │ └── zip_spec.rb │ ├── provider_spec.rb │ ├── providers │ │ ├── anynines_spec.rb │ │ ├── azure_web_apps_spec.rb │ │ ├── bintray_spec.rb │ │ ├── bluemixcloudfoundry_spec.rb │ │ ├── boxfuse_spec.rb │ │ ├── cargo_spec.rb │ │ ├── chef_supermarket_spec.rb │ │ ├── cloud66_spec.rb │ │ ├── cloudfiles_spec.rb │ │ ├── cloudformation_spec.rb │ │ ├── cloudfoundry_spec.rb │ │ ├── codedeploy_spec.rb │ │ ├── convox_spec.rb │ │ ├── datica_spec.rb │ │ ├── ecr_spec.rb │ │ ├── elasticbeanstalk_spec.rb │ │ ├── engineyard_spec.rb │ │ ├── firebase_spec.rb │ │ ├── flynn_spec.rb │ │ ├── gae_spec.rb │ │ ├── gcs_spec.rb │ │ ├── git_push_spec.rb │ │ ├── gleis_spec.rb │ │ ├── hackage_spec.rb │ │ ├── hephy_spec.rb │ │ ├── heroku │ │ │ ├── api_spec.rb │ │ │ └── git_spec.rb │ │ ├── lambda_spec.rb │ │ ├── launchpad_spec.rb │ │ ├── netlify_spec.rb │ │ ├── npm_spec.rb │ │ ├── nuget_spec.rb │ │ ├── openshift_spec.rb │ │ ├── opsworks_spec.rb │ │ ├── packagecloud_spec.rb_ │ │ ├── pages │ │ │ ├── api_spec.rb │ │ │ └── git_spec.rb │ │ ├── puppetforge_spec.rb │ │ ├── pypi_spec.rb │ │ ├── releases_spec.rb │ │ ├── rubygems_spec.rb │ │ ├── s3_spec.rb │ │ ├── scalingo_spec.rb │ │ ├── script_spec.rb │ │ ├── snap_spec.rb │ │ ├── surge_spec.rb │ │ ├── testfairy_spec.rb │ │ └── transifex_spec.rb │ └── support │ │ ├── gems_spec.rb │ │ └── version_spec.rb ├── fixtures │ ├── bintray │ │ └── descriptor.json │ └── engineyard │ │ ├── app_env_multi.json │ │ ├── app_env_none.json │ │ ├── app_env_one.json │ │ ├── auth.json │ │ ├── deploy.json │ │ ├── deployment.json │ │ └── user.json ├── spec_helper.rb ├── support.rb └── support │ ├── cl.rb │ ├── ctx.rb │ ├── env.rb │ ├── file.rb │ ├── fixtures.rb │ ├── gemfile.rb │ ├── helpers.rb │ ├── matchers.rb │ ├── matchers │ ├── aws.rb │ ├── have_deprecated.rb │ ├── have_env.rb │ ├── have_logged.rb │ ├── have_run.rb │ ├── have_written.rb │ ├── have_zipped.rb │ └── shared.rb │ ├── now.rb │ └── require.rb └── status.json /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-pro 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | .coverage 4 | .dpl 5 | .yardoc 6 | Gemfile.lock 7 | NOTES.md 8 | coverage 9 | google_appengine/* 10 | google_appengine_*.zip 11 | npm-debug.log 12 | play 13 | setuptools*.zip 14 | stubs 15 | vendor 16 | tmp 17 | 18 | # Ignore editor specific configs 19 | /.idea 20 | /.vscode 21 | .project 22 | .classpath 23 | .c9/ 24 | *.launch 25 | .settings/ 26 | *.sublime-workspace 27 | .generators 28 | .rakeTasks 29 | 30 | # System Files 31 | .DS_Store 32 | Thumbs.db 33 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | --color 3 | --tty 4 | --tag ~skip 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: rubocop-performance 2 | require: rubocop-rspec 3 | 4 | Documentation: 5 | Enabled: false 6 | Metrics/ClassLength: 7 | Enabled: false 8 | Style/ClassAndModuleChildren: 9 | Enabled: false 10 | Metrics/LineLength: 11 | Enabled: false 12 | Metrics/MethodLength: 13 | Max: 40 14 | Style/AsciiComments: 15 | Enabled: false 16 | Metrics/AbcSize: 17 | Enabled: false 18 | Style/GuardClause: 19 | Enabled: false 20 | Style/FormatStringToken: 21 | Enabled: false 22 | Lint/AssignmentInCondition: 23 | Enabled: false 24 | Style/IfUnlessModifier: 25 | Enabled: false 26 | Naming/MemoizedInstanceVariableName: 27 | EnforcedStyleForLeadingUnderscores: required 28 | Style/MultilineBlockChain: 29 | Enabled: false 30 | Lint/ConstantDefinitionInBlock: 31 | Enabled: false 32 | Naming/VariableNumber: 33 | Enabled: false 34 | Metrics/BlockLength: 35 | Enabled: false 36 | Lint/ImplicitStringConcatenation: 37 | Enabled: false 38 | Metrics/MethodLength: 39 | Enabled: false 40 | Style/StructInheritance: 41 | Enabled: false 42 | Lint/RescueException: 43 | Enabled: false 44 | Lint/SuppressedException: 45 | Enabled: false 46 | Naming/MemoizedInstanceVariableName: 47 | Enabled: false 48 | Style/SymbolProc: 49 | Enabled: false 50 | RSpec/MultipleMemoizedHelpers: 51 | Enabled: false -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: focal 2 | 3 | language: ruby 4 | rvm: 5 | - 3.1 6 | - 3.2 7 | - 3.3 8 | 9 | cache: 10 | - bundler 11 | 12 | script: 13 | - bundle exec rspec 14 | 15 | jobs: 16 | include: 17 | - &job 18 | stage: test runtime dependency installation 19 | if: commit_message !~ /skip:test_dependencies/ AND env(SKIP_TEST_DEPENDENCIES) IS blank 20 | cache: false 21 | install: 22 | - rvm use 3.3 --install --binary --fuzzy 23 | - gem build dpl.gemspec 24 | - gem install dpl-*.gem 25 | # - gem update --system 26 | - nvm install 18.20.2 27 | - nvm use 18.20.2 28 | - node --version 29 | script: 30 | - .travis/test_install 31 | rvm: 3.3 32 | - <<: *job 33 | language: python 34 | python: 2.7 35 | - <<: *job 36 | language: python 37 | python: 3.7 38 | - <<: *job 39 | language: python 40 | python: 3.8 41 | - <<: *job 42 | language: python 43 | python: 3.9 44 | - <<: *job 45 | language: python 46 | python: 3.10 47 | - <<: *job 48 | language: python 49 | python: 3.11 50 | -------------------------------------------------------------------------------- /.travis/blank.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/travis-ci/dpl/8c6eabc699178e992236adf4472f1753b7b292ce/.travis/blank.yml -------------------------------------------------------------------------------- /.travis/providers/anynines/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir_p 'tmp/dpl_test' 13 | chdir 'tmp/dpl_test' 14 | 15 | File.write 'manifest.yml', <<~str 16 | applications: 17 | - name: dpl-test 18 | instances: 1 19 | str 20 | 21 | File.write 'config.ru', <<~str 22 | require 'rack' 23 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 24 | str 25 | 26 | File.write 'Gemfile', <<~str 27 | source 'https://rubygems.org' 28 | gem 'rack' 29 | str 30 | 31 | run 'bundle install' 32 | -------------------------------------------------------------------------------- /.travis/providers/anynines/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.de.a9sapp.eu/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | puts "polling: #{url} ..." 18 | actual = poll(url) 19 | puts "expected: #{expected.inspect}" 20 | puts "actual: #{actual.inspect}" 21 | exit 0 if actual == expected 22 | sleep 5 23 | end 24 | 25 | abort 'failed' 26 | -------------------------------------------------------------------------------- /.travis/providers/anynines/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/anynines/prepare 8 | - cd tmp/dpl_test 9 | - ls -al 10 | 11 | deploy: 12 | - provider: anynines 13 | 14 | username: dpl-test@travis-ci.org 15 | password: 16 | secure: "dopn4dUR3YruM9pZmdOPlUeAibxBZ9vcWZkG9lQo4KCXBsrqU/B1oeRy9fd9/dOewJHGlaY23gHaxFodOVwZpr6yCIzLn4uVO7r+pNlFuwZHOBlVlqI1Qoumoc8qsoGorRd0yfD5VCa4MjOvsOIEShuEIdmnSFRHf03gdDJM1Us=" 17 | organization: dpl-test_travis-ci_org 18 | space: test 19 | app_name: dpl-test 20 | buildpack: ruby_buildpack 21 | logout: false 22 | 23 | after_deploy: 24 | - cd ../.. 25 | - .travis/providers/anynines/test || TRAVIS_TEST_RESULT=$? 26 | - tmp/dpl_test/cf scale dpl-test -i 0 27 | -------------------------------------------------------------------------------- /.travis/providers/aws-elasticbeanstalk/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p "#{dir}/.ebextensions" 9 | chdir dir 10 | 11 | File.write 'Gemfile', <<~str 12 | source 'https://rubygems.org' 13 | gem 'rack' 14 | str 15 | 16 | File.write 'config.ru', <<~str 17 | require 'rack' 18 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 19 | str 20 | 21 | File.write '.ebextensions/gem_install_bundler.config', <<~str 22 | files: 23 | # Runs before `./10_bundle_install.sh`: 24 | "/opt/elasticbeanstalk/hooks/appdeploy/pre/09_gem_install_bundler.sh" : 25 | mode: "000775" 26 | owner: root 27 | group: users 28 | content: | 29 | #!/usr/bin/env bash 30 | 31 | EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir) 32 | EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir) 33 | # Source the application's ruby, i.e. 2.6. Otherwise it will be 2.3, which will give this error: `bundler requires Ruby version >= 2.3.0` 34 | . $EB_SCRIPT_DIR/use-app-ruby.sh 35 | 36 | cd $EB_APP_STAGING_DIR 37 | echo "Installing compatible bundler" 38 | gem install bundler -v 2.0.1 39 | str 40 | 41 | File.write '.ebignore', <<~str 42 | * 43 | !Gemfile 44 | !config.ru 45 | !.ebextensions/gem_install_bundler.config 46 | str 47 | 48 | File.write 'secret.txt', 'secret' 49 | -------------------------------------------------------------------------------- /.travis/providers/aws-elasticbeanstalk/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'http://dpl-test.eu-central-1.elasticbeanstalk.com' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/aws-elasticbeanstalk/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/aws-elasticbeanstalk/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: elasticbeanstalk 12 | 13 | # dpl_test 14 | access_key_id: 15 | secure: "b8BMnGujyCJHcOpG1lS5w/b7MeL9dFo87LIodMv0/dn6fWIIfPbWVzK8A0ZEGGiYskJ89vZtfMwB2X5NzWlob3UJvDhEOGTaCUPoQDHlRtwVXL0HG5k6a2i6DJ7P24OdHe7t64Lxota3lGt4pESa7Js08GEjrjaQc7oyGcS5hX4=" 16 | secret_access_key: 17 | secure: "dEg7g2CzQRGw/Ao0w9TW2lFQJUFnL9ou2DMCZqnlauJircy8VWNbY2oqbe4yqkyFkr9VmXEF7zCtiSlZm/RwYHbAH3unuw2a7/3M6fw3jcSIrMA3I0TAlLPt0HGF4Ohu8jPQLy2wq26WE/71vIoEIuVUxJAmx5I6z4+B4L0jBIQ=" 18 | 19 | region: eu-central-1 20 | app: dpl-test 21 | env: DplTest-env 22 | bucket_name: travis-dpl-test-elasticbeanstalk 23 | debug: true 24 | 25 | after_deploy: 26 | - cd ../.. 27 | - .travis/providers/aws-elasticbeanstalk/test || TRAVIS_TEST_RESULT=$? 28 | -------------------------------------------------------------------------------- /.travis/providers/aws-lambda/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'index.js', <<~str 12 | exports.handler = async (event, context) => { 13 | return '#{ENV['ID']}'; 14 | }; 15 | str 16 | 17 | puts 'zip index.zip index.js' 18 | system 'zip index.zip index.js' 19 | -------------------------------------------------------------------------------- /.travis/providers/aws-lambda/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | $stdout.sync = true 4 | $stderr.sync = true 5 | 6 | require 'aws-sdk-lambda' 7 | 8 | expected = ENV['ID'] 9 | 10 | creds = Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']) 11 | client = Aws::Lambda::Client.new(region: 'eu-central-1', credentials: creds) 12 | 13 | def poll(client) 14 | resp = client.invoke( 15 | function_name: 'dpl-test', 16 | invocation_type: 'RequestResponse' 17 | ) 18 | resp.payload.read.to_s.gsub('"', '') 19 | rescue => e 20 | puts e.message 21 | end 22 | 23 | 20.times do 24 | actual = poll(client) 25 | puts "expected: #{expected.inspect}" 26 | puts "actual: #{actual.inspect}" 27 | exit 0 if actual == expected 28 | sleep 5 29 | end 30 | 31 | abort 'failed' 32 | -------------------------------------------------------------------------------- /.travis/providers/aws-lambda/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | env: 4 | - secure: "RIHfGfsaXpGKD/4JoOqLSz+BdD02GU3l730FoItRPyP+/6/if3c00LW8MkxeHitQOOBS97492GOQtLa0l1pZ+W4eiIvl3fLYbzKGep+EV5F05fZF8koOeUdcYdiLPnMVsmkgY0YzHInI6edsgbfyrlvdIw3mWszkCFhWkpKW86A=" 5 | - secure: "l7pvhRR8o/ziU3vgnAcwmg7UoVy2yEdVdJ3eip3FeKpy4f1BWhjR0RC2psSe6HTdUb/AzKSN3o+IGrycAc9oVXgVSa/dmjDnB55N/GddI/vkB9I2qDPc419OhAd2rUkJxS1qKMT70U2B2fLVYtAFF0nw11xAGIX7Ik1kmkcHoQQ=" 6 | 7 | script: 8 | - true 9 | 10 | before_deploy: 11 | - .travis/providers/aws-lambda/prepare 12 | - cd tmp/dpl_test 13 | 14 | deploy: 15 | - provider: lambda 16 | 17 | # dpl_test 18 | access_key_id: 19 | secure: "b8BMnGujyCJHcOpG1lS5w/b7MeL9dFo87LIodMv0/dn6fWIIfPbWVzK8A0ZEGGiYskJ89vZtfMwB2X5NzWlob3UJvDhEOGTaCUPoQDHlRtwVXL0HG5k6a2i6DJ7P24OdHe7t64Lxota3lGt4pESa7Js08GEjrjaQc7oyGcS5hX4=" 20 | secret_access_key: 21 | secure: "dEg7g2CzQRGw/Ao0w9TW2lFQJUFnL9ou2DMCZqnlauJircy8VWNbY2oqbe4yqkyFkr9VmXEF7zCtiSlZm/RwYHbAH3unuw2a7/3M6fw3jcSIrMA3I0TAlLPt0HGF4Ohu8jPQLy2wq26WE/71vIoEIuVUxJAmx5I6z4+B4L0jBIQ=" 22 | 23 | region: eu-central-1 24 | function_name: dpl-test 25 | role: arn:aws:iam::341288657826:role/lambda_basic_execution 26 | handler_name: handler 27 | zip: index.zip 28 | 29 | after_deploy: 30 | - cd ../.. 31 | - gem install aws-sdk-lambda 32 | - .travis/providers/aws-lambda/test || TRAVIS_TEST_RESULT=$? 33 | -------------------------------------------------------------------------------- /.travis/providers/aws-s3/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'dpl_test', ENV['ID'] 12 | -------------------------------------------------------------------------------- /.travis/providers/aws-s3/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = 'https://s3.amazonaws.com/travis-dpl-test/dpl_test' 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | actual = poll(url) 19 | puts "expected: #{expected.inspect}" 20 | puts "actual: #{actual.inspect}" 21 | exit 0 if actual == expected 22 | sleep 5 23 | end 24 | 25 | abort 'failed' 26 | -------------------------------------------------------------------------------- /.travis/providers/aws-s3/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/aws-s3/prepare 8 | 9 | deploy: 10 | - provider: s3 11 | 12 | # dpl_test 13 | access_key_id: 14 | secure: "b8BMnGujyCJHcOpG1lS5w/b7MeL9dFo87LIodMv0/dn6fWIIfPbWVzK8A0ZEGGiYskJ89vZtfMwB2X5NzWlob3UJvDhEOGTaCUPoQDHlRtwVXL0HG5k6a2i6DJ7P24OdHe7t64Lxota3lGt4pESa7Js08GEjrjaQc7oyGcS5hX4=" 15 | secret_access_key: 16 | secure: "dEg7g2CzQRGw/Ao0w9TW2lFQJUFnL9ou2DMCZqnlauJircy8VWNbY2oqbe4yqkyFkr9VmXEF7zCtiSlZm/RwYHbAH3unuw2a7/3M6fw3jcSIrMA3I0TAlLPt0HGF4Ohu8jPQLy2wq26WE/71vIoEIuVUxJAmx5I6z4+B4L0jBIQ=" 17 | 18 | bucket: travis-dpl-test 19 | local_dir: ./tmp/dpl_test 20 | 21 | # why does deploy.run not work here? 22 | after_deploy: 23 | - .travis/providers/aws-s3/test || TRAVIS_TEST_RESULT=$? 24 | -------------------------------------------------------------------------------- /.travis/providers/azure_web_apps/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir 'tmp' unless File.directory?('tmp') 13 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 14 | chdir 'tmp/dpl_test' 15 | 16 | File.write 'index.html', ENV['ID'] 17 | 18 | run 'git init .' 19 | run 'git add .' 20 | run "git commit -m 'test dpl azure_web_apps #{ENV['ID']}'" 21 | -------------------------------------------------------------------------------- /.travis/providers/azure_web_apps/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | $stdout.sync = true 4 | 5 | require 'open-uri' 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.azurewebsites.net/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/azure_web_apps/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | # - .travis/providers/azure_web_apps/scale 1 8 | - .travis/providers/azure_web_apps/prepare 9 | - cd tmp/dpl_test 10 | 11 | deploy: 12 | - provider: azure_web_apps 13 | site: dpl-test 14 | username: dpltest 15 | password: 16 | secure: "qW6Hw1lOeIpL/ISP0XVfoYveVxaWnZ+1yyTvEZ3whM9QS3tnepv45IOYem+yOkV0jzQH62rw2dQNBWsQjZkG3uTqmsRQ33BQq2l6Pg/9XeepkycNlpB1e4AEPnsjch1MtqaYnRafEaCc8f34ykOXBZtzuP4pyAXWczywJ2f55m8=" 17 | 18 | after_deploy: 19 | - cd ../.. 20 | - .travis/providers/azure_web_apps/test || TRAVIS_TEST_RESULT=$? 21 | # - .travis/providers/azure_web_apps/scale 0 22 | -------------------------------------------------------------------------------- /.travis/providers/bintray/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'bundler/inline' 4 | require 'fileutils' 5 | 6 | include FileUtils 7 | 8 | mkdir_p 'tmp/dpl_test' 9 | 10 | File.write 'tmp/dpl_test/upload.json', <<~str 11 | { 12 | "package": { 13 | "name": "dpl_test", 14 | "repo": "dpl_test", 15 | "subject": "dpl-test", 16 | "licenses": ["MIT"], 17 | "vcs_url": "https://github.com/travis-ci/dpl_test" 18 | }, 19 | "version": { 20 | "name": "#{ENV["ID"]}" 21 | }, 22 | "files": [ 23 | { 24 | "includePattern": "tmp/dpl_test/(test)", 25 | "uploadPattern": "$1" 26 | } 27 | ], 28 | "publish": true 29 | } 30 | str 31 | 32 | File.write 'tmp/dpl_test/test', ENV['ID'] 33 | -------------------------------------------------------------------------------- /.travis/providers/bintray/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = "https://bintray.com/dpl-test/dpl_test/download_file?file_path=dpl_test%2F#{ENV['ID']}%2Ftest" 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | puts "Checking #{url}" 18 | actual = poll(url) 19 | puts "expected: #{expected.inspect}" 20 | puts "actual: #{actual.inspect}" 21 | exit 0 if actual == expected 22 | sleep 5 23 | end 24 | 25 | abort 'failed' 26 | -------------------------------------------------------------------------------- /.travis/providers/bintray/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | env: 4 | # BINTRAY_API_KEY=[api key] 5 | 6 | install: true 7 | script: true 8 | 9 | before_deploy: 10 | - .travis/providers/bintray/prepare 11 | - ls -al tmp tmp/dpl_test 12 | - cat tmp/dpl_test/upload.json 13 | 14 | deploy: 15 | - provider: bintray 16 | file: tmp/dpl_test/upload.json 17 | user: dpl-test 18 | key: 19 | secure: "sPWJoIT7PTw3n68hGQOWDS5vduDuSO691yb8n0pJ8RuOM07ogN3P1c0WsdYyViV7g9FilEJLJs2GvtQ7Uhkwwrz/RS3SyuzNk/aD9H5kAIghTdJ+MZl7wQTPXHIhqqcA9nbJoGUOON5/zL3qv94+5BPDdVJhmxW0guidue4x/6U=" 20 | 21 | after_deploy: 22 | - .travis/providers/bintray/test || TRAVIS_TEST_RESULT=$? 23 | -------------------------------------------------------------------------------- /.travis/providers/bluemixcloudfoundry/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl_test' 8 | chdir 'tmp/dpl_test' 9 | 10 | File.write 'manifest.yml', <<~str 11 | applications: 12 | - name: dpl-test 13 | instances: 1 14 | str 15 | 16 | File.write 'config.ru', <<~str 17 | require 'rack' 18 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 19 | str 20 | 21 | File.write 'Gemfile', <<~str 22 | source 'https://rubygems.org' 23 | ruby '2.5.3' 24 | gem 'rack' 25 | str 26 | 27 | File.write 'Gemfile.lock', <<~str 28 | GEM 29 | remote: https://rubygems.org/ 30 | specs: 31 | rack (2.0.7) 32 | 33 | PLATFORMS 34 | ruby 35 | 36 | DEPENDENCIES 37 | rack 38 | str 39 | -------------------------------------------------------------------------------- /.travis/providers/bluemixcloudfoundry/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.eu-gb.mybluemix.net/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/bluemixcloudfoundry/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/bluemixcloudfoundry/prepare 8 | - cd tmp/dpl_test 9 | - ls -al 10 | 11 | deploy: 12 | - provider: bluemixcloudfoundry 13 | 14 | api: https://api.eu-gb.bluemix.net 15 | username: dpl-test@travis-ci.org 16 | password: 17 | secure: "pQoIDL66z8G+I4fVs/TLBM3hwGisuk1yXVvoULXXiR4ivqVgisaOK1cZ/syPwOjhZXhychpWhebX34oPkUHE8N4kCfyGbKC/y83fnKkcQ7Pt5XDOTVMcG/Bd4i7jFGhvnz4Mz7tdYO98uD2xuDyU1Qth5lF7ae921Ig2XygmxnQ=" 18 | organization: dpl-test 19 | space: dev 20 | app_name: dpl-test 21 | buildpack: ruby_buildpack 22 | logout: false 23 | 24 | after_deploy: 25 | - cd ../.. 26 | - .travis/providers/bluemixcloudfoundry/test || TRAVIS_TEST_RESULT=$? 27 | - tmp/dpl_test/cf scale dpl-test -i 0 28 | -------------------------------------------------------------------------------- /.travis/providers/boxfuse/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func handler(w http.ResponseWriter, r *http.Request) { 9 | fmt.Fprintf(w, "__ID__") 10 | } 11 | 12 | func main() { 13 | http.HandleFunc("/", handler) 14 | http.ListenAndServe(":8080", nil) 15 | } 16 | -------------------------------------------------------------------------------- /.travis/providers/boxfuse/prepare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp/dpl_test 4 | cat .travis/providers/boxfuse/main.go | sed "s/__ID__/$ID/g" > tmp/dpl_test/main.go 5 | 6 | cd tmp/dpl_test 7 | 8 | export GOOS=linux 9 | 10 | go build -ldflags="-s" 11 | 12 | mkdir conf 13 | echo 'ports.http=8080' > boxfuse.conf 14 | -------------------------------------------------------------------------------- /.travis/providers/boxfuse/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'http://dpltest-travisdpltest.boxfuse.io:8080/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/boxfuse/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | install: true 4 | script: true 5 | 6 | env: 7 | # BOXFUSE_USER=[boxfuse user] 8 | - secure: "kwvAcjVm71MO6682XLxpwv2hmlNzplfDS116CDJUQ3QQzHg0olSv/bSkp0aCEmDDCsqVPnmEABNSnAP7Y6fddG6dRAFY2D93/JRpeLo3kfUAubckx7v9sCJz+xPRyUyVZIhfjFcjJ3xKoVJ14NdO1lICNA6gL/F1XYkll8xlHSw=" 9 | # BOXFUSE_SECRET=[boxfuse secret] 10 | - secure: "BWNbYYMLWPOe+eMkXayY9Xl/S3fR6QCBYJn826qJdZzgAXwvE8kl5Hgnac0f3X+tYsn4pSNSM4QuAm/vmMLxQNzlfcw4FDFNlIo2GIxzTwlOR8rCDpmTmxBSK0uomMcpaKxqkuqbUJmos0Ttm+Vh0vxw8/hZ55TTEXbL+b9ShkY=" 11 | 12 | before_deploy: 13 | - .travis/providers/boxfuse/prepare 14 | - cd tmp/dpl_test 15 | 16 | deploy: 17 | - provider: boxfuse 18 | user: 19 | secure: "TmfDWdpCryBNzDEiPwMdjQQt9IE1Pt8L7VMF597YjWl1xC2OAFvxQ5hk7gqDioYPz2/5xzMfLdRuyejcL9u6QQxMuCgHhfadJn6dwnhbO6uR9x72KY6FLXL5bsW/+XQTS+HwUvGq7xwka7An8QNUGMsFfvdHy5VZT5qRvPVWIN4=" 20 | secret: 21 | secure: "pSNJxd9xH+4EZ+0cHCqsgyjzLyI/hZK7g3SdPGqcQu90EOD6qzm1ET9Wt8eYWAxruKf8o03rEwKfAEdk84N36JxH+57AVLQh2UUM2+jjovXL8VDvpbekbXxisT4TKpzL7fxNpY+/4gkDPnJz/7g9sFbc9WO5ntOBsn7d+vT/FqQ=" 22 | env: prod 23 | payload: dpl_test 24 | config_file: boxfuse.conf 25 | 26 | after_deploy: 27 | - ../../.travis/providers/boxfuse/test || TRAVIS_TEST_RESULT=$? 28 | - boxfuse/boxfuse kill dpltest -env=prod 29 | - boxfuse/boxfuse rm 30 | -------------------------------------------------------------------------------- /.travis/providers/cargo/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl_test/src' 8 | chdir 'tmp/dpl_test' 9 | 10 | system 'git init .' 11 | 12 | File.write 'Cargo.toml', <<~str 13 | [package] 14 | name = "dpl_test" 15 | version = "0.0.1-test.#{ENV['ID']}" 16 | description = "Travis CI dpl test package" 17 | license = "MIT" 18 | authors = ["Travis CI "] 19 | str 20 | 21 | File.write 'src/lib.rs', <<~str 22 | mod tests { 23 | #[test] 24 | fn it_works() { 25 | } 26 | } 27 | str 28 | -------------------------------------------------------------------------------- /.travis/providers/cargo/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = 'https://crates.io/api/v1/crates/dpl-test' 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | puts "Checking #{url}" 19 | data = JSON.load(poll(url)) 20 | actual = data['versions'].map { |version| version['num'].split('.').last } 21 | puts "expected: #{expected.inspect}" 22 | puts "actual: #{actual.inspect}" 23 | exit 0 if actual.include?(expected) 24 | sleep 5 25 | end 26 | 27 | abort 'failed' 28 | -------------------------------------------------------------------------------- /.travis/providers/cargo/travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: rust 3 | 4 | script: 5 | - true 6 | 7 | before_deploy: 8 | - .travis/providers/cargo/prepare 9 | - cd tmp/dpl_test 10 | 11 | deploy: 12 | - provider: cargo 13 | allow_dirty: true 14 | token: 15 | secure: "nlMiqpZRZdJ7Q66jpsIaHst/qNQS5sGQyIZrpjWUWw/mKe0Hdgxdu0FzLA46rmJK2hwE5hIw2oGtlMyy6zaAitRu3GI60fd0ABN/HOwntcyL+IrcftQe0ZqaEMW9dWoQo7I2UWNujVFYPDTrckRogN8AXrEwK0bnOPS1fuxmJ4U=" 16 | 17 | after_deploy: 18 | - cd ../.. 19 | - .travis/providers/cargo/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/chef_supermarket/delete: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # it appears deleting cookbooks is disabled on Chef Supermarket: 4 | # 5 | # status: 403 6 | # body: {"error_code":"FORBIDDEN","error_messages":["You are not authorized to destroy this cookbook. If you are the cookbook owner, this Supermarket has disabled artifact removal by owner per Chef RFC072. Contact the administrators if there are concerns."]} 7 | 8 | # require 'openssl' 9 | # require 'openssl/digest' 10 | # require 'mixlib/authentication/signedheaderauth' 11 | # require 'net/http' 12 | # 13 | # url = 'https://supermarket.chef.io/api/v1/cookbooks/dpl_test' 14 | # user = 'dpl-test' 15 | # key = 'tmp/dpl_test/private_key' 16 | # 17 | # uri = URI.parse(url) 18 | # key = OpenSSL::PKey::RSA.new(File.read(key)) 19 | # now = Time.now.utc.iso8601 20 | # 21 | # sign = { 22 | # http_method: 'DELETE', 23 | # path: uri.path, 24 | # body: '', 25 | # user_id: user, 26 | # timestamp: now 27 | # } 28 | # 29 | # headers = Mixlib::Authentication::SignedHeaderAuth.signing_object(sign).sign(key) 30 | # 31 | # req = Net::HTTP::Delete.new(uri.path, headers) 32 | # http = Net::HTTP.new(uri.host, uri.port) 33 | # http.use_ssl = true 34 | # 35 | # res = http.request(req) 36 | # puts res.code 37 | # puts res.body 38 | # 39 | -------------------------------------------------------------------------------- /.travis/providers/chef_supermarket/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p "#{dir}/recipes" 9 | chdir dir 10 | 11 | File.write 'README.md', <<~str 12 | Travis CI Dpl Test 13 | str 14 | 15 | File.write 'metadata.json', <<~str 16 | { 17 | "name": "dpl_test", 18 | "version": "0.0.#{ENV['TRAVIS_BUILD_NUMBER']}", 19 | "description": "Test package for integration testing Travis CI deployment integration with Chef Supermarket", 20 | "maintainer": "Travis CI Dpl Test", 21 | "maintainer_email": "contact@travis-ci.com", 22 | "license": "MIT", 23 | "recipes": { 24 | "dpl-test": "Travis CI Dpl Test" 25 | } 26 | } 27 | str 28 | 29 | File.write 'recipes/default.rb', <<~str 30 | log "#{ENV['ID']}" 31 | str 32 | -------------------------------------------------------------------------------- /.travis/providers/chef_supermarket/private_key.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/travis-ci/dpl/8c6eabc699178e992236adf4472f1753b7b292ce/.travis/providers/chef_supermarket/private_key.enc -------------------------------------------------------------------------------- /.travis/providers/chef_supermarket/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['TRAVIS_BUILD_NUMBER'] 9 | url = 'https://supermarket.chef.io/api/v1/cookbooks/dpl_test' 10 | 11 | def poll(url) 12 | puts "Checking #{url}" 13 | uri = URI.parse(url) 14 | data = JSON.load(uri) 15 | data['latest_version'] =~ /0\.0\.(.*)/ && $1 16 | rescue => e 17 | puts e.message 18 | nil 19 | end 20 | 21 | 10.times do 22 | actual = poll(url) 23 | puts "expected: #{expected.inspect}" 24 | puts "actual: #{actual.inspect}" 25 | exit 0 if actual == expected 26 | sleep 5 27 | end 28 | 29 | abort 'failed' 30 | -------------------------------------------------------------------------------- /.travis/providers/chef_supermarket/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - mkdir -p tmp/dpl_test 8 | - openssl aes-256-cbc -K $encrypted_ee862e3b87bc_key -iv $encrypted_ee862e3b87bc_iv -in .travis/providers/chef_supermarket/private_key.enc -out tmp/dpl_test/private_key -d 9 | - .travis/providers/chef_supermarket/prepare 10 | 11 | deploy: 12 | - provider: chef_supermarket 13 | user_id: dpl-test 14 | client_key: private_key 15 | category: Other 16 | dir: tmp/dpl_test 17 | 18 | after_deploy: 19 | - .travis/providers/chef_supermarket/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/cloud66/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | netrc = File.expand_path('~/.netrc') 13 | 14 | File.write netrc, <<~str 15 | machine github.com 16 | login #{ENV['GITHUB_TOKEN']} 17 | str 18 | File.chmod 0600, netrc 19 | 20 | mkdir 'tmp' unless File.directory?('tmp') 21 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 22 | chdir 'tmp/dpl_test' 23 | run 'git checkout cloud66' 24 | 25 | File.write 'app/views/home/index.html.erb', ENV['ID'] 26 | 27 | run 'git add .' 28 | run "git commit -m 'test dpl cloud66 #{ENV['ID']}'" 29 | run 'git push -f origin cloud66' 30 | -------------------------------------------------------------------------------- /.travis/providers/cloud66/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'http://dpl-test-app-dpl-test.apps.us-west-2.online-starter.openshift.com/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/cloud66/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | env: 4 | # GITHUB_TOKEN=[personal access token with repo scope on travis-dpl-test] 5 | secure: "o7IxUSrMNTYoVqWO+LkmGn3wccPEEi9CewntdP/KGgH1g8YdDuEjZvSmSlNacEsXfibz+F3pWM1aNb3Qx5Is0fQizm0eVaAXs/4qwPZOyByzOt5QdO0PXw4BRuojc6kByW0QcsbUceyxUSFNQeWernpinlZAnblpLBjTpqbPKSw=" 6 | 7 | install: true 8 | script: true 9 | 10 | before_deploy: 11 | - .travis/providers/cloud66/prepare 12 | 13 | deploy: 14 | - provider: cloud66 15 | redeployment_hook: 16 | secure: "rINFSEWO0rOOpxFoHUTDxzRs4rJgaKlNpqRPZ5HAG8UPyaGtw9qqMENWUHIMJaNPOtYFQYfEbCGYdluTrJ1rvBMuZ3RpS7ylrzC3obKi1mVpZvrbFujkFHlUCQFm4tiSXlpbClmq4aXq/1EW9R6+8n8+9hzelzomQMn/ItNb2QE=" 17 | 18 | after_deploy: 19 | - .travis/providers/cloud66/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/cloudfoundry/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir_p 'tmp/dpl_test' 13 | chdir 'tmp/dpl_test' 14 | 15 | File.write 'manifest.yml', <<~str 16 | applications: 17 | - name: dpl-test 18 | instances: 1 19 | str 20 | 21 | File.write 'config.ru', <<~str 22 | require 'rack' 23 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 24 | str 25 | 26 | File.write 'Gemfile', <<~str 27 | source 'https://rubygems.org' 28 | gem 'rack' 29 | str 30 | 31 | run 'bundle install' 32 | -------------------------------------------------------------------------------- /.travis/providers/cloudfoundry/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.cfapps.io/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/cloudfoundry/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/cloudfoundry/prepare 8 | - cd tmp/dpl_test 9 | - ls -al 10 | 11 | deploy: 12 | - provider: cloudfoundry 13 | username: dpl-test@travis-ci.org 14 | password: 15 | secure: "cEUSQKSUNkpqz1az/7mJyTCpjaeHAED++DhdQ02YgvjmW5N/r4UE+nv/r7v2SDVbHoVViphezCvf6+owB+9k0Zl05dXQWA3521Cj3At+zVq2p8yXegVHkZy4YLDnUrPPfSLHT1wvpa0MrtiylKs0eo65kEupD494qH3VZPGRRuU=" 16 | organization: dpl-test 17 | space: dev 18 | app_name: dpl-test 19 | buildpack: ruby_buildpack 20 | 21 | after_deploy: 22 | - cd ../.. 23 | - .travis/providers/cloudfoundry/test || TRAVIS_TEST_RESULT=$? 24 | - tmp/dpl_test/cf scale dpl-test -i 0 25 | -------------------------------------------------------------------------------- /.travis/providers/datica/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir_p 'tmp/dpl_test' 13 | chdir 'tmp/dpl_test' 14 | run 'git init .' 15 | 16 | File.write 'Procfile', <<~str 17 | web: node main.js 18 | str 19 | 20 | File.write 'package.json', <<~str 21 | { 22 | "name": "dpl-test", 23 | "private": true 24 | } 25 | str 26 | 27 | File.write 'main.js', <<~str 28 | const http = require('http'); 29 | 30 | const hostname = '127.0.0.1'; 31 | const port = process.env.PORT || 8080; 32 | 33 | const server = http.createServer((req, res) => { 34 | res.statusCode = 200; 35 | res.setHeader('Content-Type', 'text/plain'); 36 | res.end('#{ENV['ID']}'); 37 | }); 38 | 39 | server.listen(port, hostname, () => { 40 | console.log(`Server running at http://${hostname}:${port}/`); 41 | }); 42 | str 43 | -------------------------------------------------------------------------------- /.travis/providers/datica/test: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/env ruby 2 | # 3 | # require 'open-uri' 4 | # 5 | # $stdout.sync = true 6 | # 7 | # expected = ENV['ID'] 8 | # url = '...' 9 | # 10 | # def poll(url) 11 | # URI.parse(url).read 12 | # rescue => e 13 | # puts e.message 14 | # end 15 | # 16 | # 20.times do 17 | # actual = poll(url) 18 | # puts "expected: #{expected.inspect}" 19 | # puts "actual: #{actual.inspect}" 20 | # exit 0 if actual == expected 21 | # sleep 5 22 | # end 23 | # 24 | # abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/datica/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/datica/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: datica 12 | 13 | after_deploy: 14 | - cd ../.. 15 | - .travis/providers/datica/test || TRAVIS_TEST_RESULT=$? 16 | -------------------------------------------------------------------------------- /.travis/providers/engineyard/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | require 'net/http' 5 | require 'open-uri' 6 | require 'json' 7 | 8 | include FileUtils 9 | 10 | def run(cmd) 11 | puts "$ #{cmd}" 12 | system(cmd) || abort 13 | end 14 | 15 | def headers 16 | { 17 | 'X-EY-TOKEN' => ENV['ENGINEYARD_TOKEN'], 18 | 'Content-Type' => 'application/json', 19 | 'Accept' => 'application/vnd.engineyard.v3+json', 20 | } 21 | end 22 | 23 | def servers 24 | uri = URI.parse('https://api.engineyard.com/servers') 25 | data = JSON.parse(uri.read(headers)) 26 | data['servers'] 27 | end 28 | 29 | servers.each do |server| 30 | run "EY_TOKEN=$ENGINEYARD_TOKEN ./ey servers start #{server['provisioned_id']}" 31 | end 32 | 33 | 34 | netrc = File.expand_path('~/.netrc') 35 | 36 | File.write netrc, <<~str 37 | machine github.com 38 | login #{ENV['GITHUB_TOKEN']} 39 | str 40 | File.chmod 0600, netrc 41 | 42 | mkdir 'tmp' unless File.directory?('tmp') 43 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 44 | chdir 'tmp/dpl_test' 45 | run 'git checkout -B engine_yard' 46 | 47 | File.write 'config.ru', <<~str 48 | require 'rack' 49 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 50 | str 51 | 52 | File.write 'id', ENV['ID'] 53 | 54 | run 'git add .' 55 | run "git commit -m 'test dpl Engine Yard #{ENV['ID']}'" 56 | run 'git push -f origin engine_yard' 57 | 58 | -------------------------------------------------------------------------------- /.travis/providers/engineyard/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'json' 4 | require 'open-uri' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = 'http://ec2-3-219-122-248.compute-1.amazonaws.com/' 10 | success = nil 11 | 12 | def poll(url) 13 | URI.parse(url).read 14 | rescue => e 15 | puts e.message 16 | end 17 | 18 | 20.times do 19 | actual = poll(url) 20 | puts "expected: #{expected.inspect}" 21 | puts "actual: #{actual.inspect}" 22 | sleep(5) && next unless actual == expected 23 | success = true 24 | break 25 | end 26 | 27 | def run(cmd) 28 | puts "$ #{cmd}" 29 | system(cmd) || abort 30 | end 31 | 32 | def headers 33 | { 34 | 'X-EY-TOKEN' => ENV['ENGINEYARD_TOKEN'], 35 | 'Content-Type' => 'application/json', 36 | 'Accept' => 'application/vnd.engineyard.v3+json', 37 | } 38 | end 39 | 40 | def servers 41 | uri = URI.parse('https://api.engineyard.com/servers') 42 | data = JSON.parse(uri.read(headers)) 43 | data['servers'] 44 | end 45 | 46 | servers.each do |server| 47 | run "EY_TOKEN=$ENGINEYARD_TOKEN ./ey servers stop #{server['provisioned_id']}" 48 | end 49 | 50 | abort 'failed' unless success 51 | -------------------------------------------------------------------------------- /.travis/providers/engineyard/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | env: 4 | # GITHUB_TOKEN=[personal access token with repo scope on travis-dpl-test] 5 | - secure: "o7IxUSrMNTYoVqWO+LkmGn3wccPEEi9CewntdP/KGgH1g8YdDuEjZvSmSlNacEsXfibz+F3pWM1aNb3Qx5Is0fQizm0eVaAXs/4qwPZOyByzOt5QdO0PXw4BRuojc6kByW0QcsbUceyxUSFNQeWernpinlZAnblpLBjTpqbPKSw=" 6 | # ENGINEYARD_TOKEN=[api key] 7 | - secure: "KXIVseBmqNgkefqqmVLNExDFpJwfVlvDw4jQSLMfTnuQpFi3VC8sTKIQywdtIHBr0xBuXsmj9jDiFb3DGIefsABDJ4ajdSqF0flabtEbTT9zUBHLcKSODX0QR5AER+rjFUrHV6U3HQfETKkRU4cDX1wEYEg03xrNQoQqZc4QAWs=" 8 | 9 | 10 | install: true 11 | script: true 12 | 13 | before_deploy: 14 | - curl -L -o ey https://github.com/ess/ey/releases/download/v0.0.1/ey-v0.0.1-linux-386 15 | - chmod +x ey 16 | - .travis/providers/engineyard/prepare 17 | - cd tmp/dpl_test 18 | - export TRAVIS_COMMIT=$(git rev-parse HEAD | tr -d '\n') 19 | 20 | deploy: 21 | - provider: engineyard 22 | app: travis_dpl_test 23 | api_key: 24 | secure: "maQqcDA51oW/kVsaC6LmB7iKy2XoRxU6UStQZfGucqkryorC19RkHaKYjtEeQQORZT/Jh3+1kCMe2vXBHSsZA1lIIfIpj/HojwUGD0qeLSefDhdR2BTf78sRL+HsRE78GX8k2ORt+OQT6JcaA+rCb6/7Wk4/IygbcHHYMS+doK0=" 25 | 26 | after_deploy: 27 | - cd ../.. 28 | - .travis/providers/engineyard/test || TRAVIS_TEST_RESULT=$? 29 | -------------------------------------------------------------------------------- /.travis/providers/firebase/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl_test' 8 | chdir 'tmp/dpl_test' 9 | 10 | File.write 'firebase.json', <<~str 11 | { 12 | "hosting": { 13 | "public": "." 14 | } 15 | } 16 | str 17 | 18 | File.write 'index.html', ENV['ID'] 19 | 20 | -------------------------------------------------------------------------------- /.travis/providers/firebase/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test-bf4fc.firebaseapp.com/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/firebase/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/firebase/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: firebase 12 | project: dpl-test-bf4fc 13 | token: 14 | secure: "KUowxrr0mZjo6UvjQMYL4ahDnVNsBJCFw16S/evIssXDP28FBLVCpxsty1MlkMzVQlQPm/hlgvByuiuOOKK1AhSvr8PBJqzAZIcg7Ijfn2vI3H2Qj1rCUJpEFhF0f7rnnoIV1kNEoWb3pcJrsporh2FT9yStcNlyvEbDVAJBh3A=" 15 | 16 | after_deploy: 17 | - cd ../.. 18 | - .travis/providers/firebase/test || TRAVIS_TEST_RESULT=$? 19 | -------------------------------------------------------------------------------- /.travis/providers/gae/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: go112 2 | 3 | handlers: 4 | - url: /.* 5 | script: auto 6 | 7 | # manual_scaling: 8 | # instances: 1 9 | 10 | # automatic_scaling: 11 | # max_num_instances: 1 12 | -------------------------------------------------------------------------------- /.travis/providers/gae/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "google.golang.org/appengine" 7 | ) 8 | 9 | func main() { 10 | http.HandleFunc("/", indexHandler) 11 | appengine.Main() 12 | } 13 | 14 | func indexHandler(w http.ResponseWriter, r *http.Request) { 15 | fmt.Fprintln(w, "__ID__") 16 | } 17 | -------------------------------------------------------------------------------- /.travis/providers/gae/prepare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp/dpl_test 4 | cat .travis/providers/gae/main.go | sed "s/__ID__/$ID/g" > tmp/dpl_test/main.go 5 | cp .travis/providers/gae/app.yaml tmp/dpl_test 6 | 7 | cd tmp/dpl_test 8 | export GOOS=linux 9 | go get 10 | go build -ldflags="-s" 11 | -------------------------------------------------------------------------------- /.travis/providers/gae/service-account.json.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/travis-ci/dpl/8c6eabc699178e992236adf4472f1753b7b292ce/.travis/providers/gae/service-account.json.enc -------------------------------------------------------------------------------- /.travis/providers/gae/start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH="/home/travis/google-cloud-sdk/bin/:$PATH" 4 | 5 | gcloud -q auth activate-service-account --key-file tmp/dpl_test/service-account.json 6 | gcloud config set project dpl-test-244917 7 | 8 | version=$(gcloud app versions list | tail -n 1 | awk '{ print $2 }') 9 | echo "Version: $version" 10 | gcloud -q app versions start $version 11 | -------------------------------------------------------------------------------- /.travis/providers/gae/stop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH="/home/travis/google-cloud-sdk/bin/:$PATH" 4 | 5 | gcloud -q auth activate-service-account --key-file tmp/dpl_test/service-account.json 6 | gcloud config set project dpl-test-244917 7 | 8 | version=$(gcloud app versions list | tail -n 1 | awk '{ print $2 }') 9 | echo "Version: $version" 10 | gcloud -q app versions stop $version 11 | -------------------------------------------------------------------------------- /.travis/providers/gae/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test-244917.appspot.com/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 40.times do 17 | actual = poll(url).chomp 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/gae/travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: go 3 | 4 | install: true 5 | script: true 6 | 7 | env: 8 | GOPATH: '/home/travis/tmp/dpl_test' 9 | 10 | before_deploy: 11 | - .travis/providers/gae/prepare 12 | - openssl aes-256-cbc -K $encrypted_b24ece17e78a_key -iv $encrypted_b24ece17e78a_iv -in .travis/providers/gae/service-account.json.enc -out tmp/dpl_test/service-account.json -d 13 | - cd tmp/dpl_test 14 | - ls -al . 15 | 16 | deploy: 17 | - provider: gae 18 | project: dpl-test-244917 19 | 20 | after_deploy: 21 | - ../../.travis/providers/gae/test || TRAVIS_TEST_RESULT=$? 22 | - gcloud -q auth activate-service-account --key-file service-account.json 23 | - gcloud app versions list --project=dpl-test-244917 | grep -v VERSION | awk '{ print $2 }' | head -n -1 | xargs gcloud app versions delete --project=dpl-test-244917 24 | -------------------------------------------------------------------------------- /.travis/providers/gcs/key.json.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/travis-ci/dpl/8c6eabc699178e992236adf4472f1753b7b292ce/.travis/providers/gcs/key.json.enc -------------------------------------------------------------------------------- /.travis/providers/gcs/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | 9 | def write(path, content) 10 | mkdir_p File.dirname(path) 11 | File.write(path, content) 12 | end 13 | 14 | write "#{dir}/index.html", ENV['ID'] 15 | write "#{dir}/foo/index.html", ENV['ID'] 16 | write "#{dir}/foo/bar/index.html", ENV['ID'] 17 | -------------------------------------------------------------------------------- /.travis/providers/gcs/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | urls = %w( 10 | https://storage.googleapis.com/dpl-test/index.html 11 | https://storage.googleapis.com/dpl-test/foo/index.html 12 | https://storage.googleapis.com/dpl-test/foo/bar/index.html 13 | ) 14 | 15 | def poll(url) 16 | puts "polling #{url} ..." 17 | URI.parse(url).read 18 | rescue => e 19 | puts e.message 20 | end 21 | 22 | 10.times do 23 | urls.each do |url| 24 | actual = poll(url) 25 | puts "expected: #{expected.inspect}" 26 | puts "actual: #{actual.inspect}" 27 | exit 0 if actual == expected 28 | sleep 5 29 | end 30 | end 31 | 32 | abort 'failed' 33 | -------------------------------------------------------------------------------- /.travis/providers/gcs/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | dist: xenial 3 | 4 | install: true 5 | script: true 6 | 7 | before_deploy: 8 | - openssl aes-256-cbc -K $encrypted_81cf70da4be5_key -iv $encrypted_81cf70da4be5_iv -in .travis/providers/gcs/key.json.enc -out key.json -d 9 | - .travis/providers/gcs/prepare 10 | - python --version 11 | 12 | deploy: 13 | - provider: gcs 14 | key_file: key.json 15 | bucket: dpl-test 16 | local_dir: ./tmp/dpl_test 17 | acl: public-read 18 | cache_control: "private, max-age=0, no-transform" 19 | detect_encoding: true 20 | 21 | after_deploy: 22 | - .travis/providers/gcs/test || TRAVIS_TEST_RESULT=$? 23 | -------------------------------------------------------------------------------- /.travis/providers/git_push/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'id', <<~str 12 | #{ENV['ID']} 13 | str 14 | 15 | # system 'git init' 16 | # system 'git add .' 17 | # system "git commit -m 'test dpl github pages #{Time.now}'" 18 | -------------------------------------------------------------------------------- /.travis/providers/git_push/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://raw.githubusercontent.com/travis-ci/dpl_test/test-git-push/id' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 10.times do 17 | actual = poll(url).chomp 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 10 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/git_push/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/git_push/prepare 8 | 9 | deploy: 10 | - provider: git_push 11 | token: 12 | # personal access token with repo and user scopes on travis-dpl-test 13 | secure: "Iq437TC76lD2pY5BceuaTqcyHt6Xq8dv+/Or6tkdzwMAltmraPKA6AB7MhQTtMVwqd5rSehNqbglzTcaXU4vk8TEGYxA9VDXD/9+9VWYGMHRh5Ql+huOoVPpW4tF+ZRUpAfogB77XRROvb8TjwI2uyO1byDtq/5jRl9CeQNv5sg=" 14 | repo: travis-ci/dpl_test 15 | local_dir: tmp/dpl_test 16 | branch: test-git-push 17 | pull_request: true 18 | 19 | after_deploy: 20 | - .travis/providers/git_push/test || TRAVIS_TEST_RESULT=$? 21 | -------------------------------------------------------------------------------- /.travis/providers/github-pages/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'index.html', <<~str 12 | #{ENV['ID']} 13 | str 14 | 15 | system 'git init' 16 | system 'git add .' 17 | system "git commit -m 'test dpl github pages #{Time.now}'" 18 | -------------------------------------------------------------------------------- /.travis/providers/github-pages/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://raw.githubusercontent.com/travis-ci/dpl_test/gh-pages/index.html' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 10.times do 17 | actual = poll(url).chomp 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/github-pages/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/github-pages/prepare 8 | 9 | deploy: 10 | - provider: pages 11 | token: 12 | # personal access token with repo and user scopes on travis-dpl-test 13 | secure: "Iq437TC76lD2pY5BceuaTqcyHt6Xq8dv+/Or6tkdzwMAltmraPKA6AB7MhQTtMVwqd5rSehNqbglzTcaXU4vk8TEGYxA9VDXD/9+9VWYGMHRh5Ql+huOoVPpW4tF+ZRUpAfogB77XRROvb8TjwI2uyO1byDtq/5jRl9CeQNv5sg=" 14 | repo: travis-ci/dpl_test 15 | committer_from_gh: true 16 | local_dir: tmp/dpl_test 17 | keep_history: true 18 | verbose: true 19 | commit_message: |- 20 | commit https://github.com/%{project_name}/commit/$TRAVIS_COMMIT 21 | 22 | successfully built and checked by Travis CI build $TRAVIS_BUILD_NUMBER. 23 | 24 | see https://travis-ci.org/%{project_name}/builds/$TRAVIS_BUILD_ID for details. 25 | 26 | after_deploy: 27 | - .travis/providers/github-pages/test || TRAVIS_TEST_RESULT=$? 28 | -------------------------------------------------------------------------------- /.travis/providers/github-releases/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p "#{dir}/foo" 9 | chdir dir 10 | 11 | File.write 'foo/dpl_test.rb', <<~str 12 | p #{ENV['ID'].inspect} 13 | str 14 | 15 | files = %w( 16 | a00_!a.txt 17 | a01_#a.txt 18 | a02_$a.txt 19 | a03_%a.txt 20 | a04_&a.txt 21 | a05_'a.txt 22 | a06_(a.txt 23 | a07_)a.txt 24 | a08_+a.txt 25 | a09_,a.txt 26 | a10_-a.txt 27 | a11_.a.txt 28 | a12_;a.txt 29 | a13_=a.txt 30 | a14_@a.txt 31 | a15_[a.txt 32 | a16_\a.txt 33 | a17_]a.txt 34 | a18_^a.txt 35 | a19__a.txt 36 | a20_`a.txt 37 | a21_{a.txt 38 | a22_}a.txt 39 | a23_~a.txt 40 | ) 41 | 42 | files.each do |file| 43 | File.write(file, 'foo') 44 | end 45 | 46 | # version = 'v0.0.0' 47 | version = "v0.0.#{ENV['TRAVIS_BUILD_NUMBER']}-#{ENV['ID']}" 48 | 49 | system 'git init' 50 | system 'git add .' 51 | system "git commit -m 'test dpl github releases #{Time.now}'" 52 | system "git tag -a #{version} -m 'version #{version}'" 53 | -------------------------------------------------------------------------------- /.travis/providers/github-releases/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = "v0.0.#{ENV['TRAVIS_BUILD_NUMBER']}-#{ENV['ID']}" 9 | url = 'https://api.github.com/repos/travis-ci/dpl_test/releases/latest' 10 | 11 | def poll(url) 12 | json = URI.parse(url).read 13 | JSON.load(json) 14 | rescue => e 15 | puts e.message 16 | {} 17 | end 18 | 19 | 10.times do 20 | puts "Checking #{url}" 21 | actual = poll(url)['tag_name'] 22 | puts "expected: #{expected.inspect}" 23 | puts "actual: #{actual.inspect}" 24 | exit 0 if actual == expected 25 | sleep 5 26 | end 27 | 28 | abort 'failed' 29 | -------------------------------------------------------------------------------- /.travis/providers/github-releases/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/github-releases/prepare 8 | - cd tmp/dpl_test 9 | - ls -al foo 10 | - "echo '**release notes**' > RELEASE_NOTES.md" 11 | 12 | deploy: 13 | - provider: releases 14 | repo: travis-ci/dpl_test 15 | 16 | target_commitish: 'master' 17 | name: 'dpl test' 18 | file: '**/*' 19 | release_notes_file: ./RELEASE_NOTES.md 20 | overwrite: true 21 | 22 | token: 23 | # personal access token with repo scope on travis-dpl-test 24 | secure: "fRVQWM14TO7/nHNyXB3fHZPKCqZxNPxN3wKmVsxVqTj99SSPsonr1AvQXziFtLEc44+pmlg0J5diFhhwzWU2W4/UxDaFyrdhkmZWRkRlJTjkgO0kDOJPJFza4stXAsavn4bLpz6YuCD0ZprPTBJu2wDA7e1IvXGRu0nb/PIaRko=" 25 | 26 | after_deploy: 27 | - cd ../.. 28 | - .travis/providers/github-releases/test || export TRAVIS_TEST_RESULT=$? 29 | -------------------------------------------------------------------------------- /.travis/providers/gleis/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | def run(cmd) 6 | puts "$ #{cmd}" 7 | system(cmd) || abort 8 | end 9 | 10 | FileUtils.mkdir 'tmp' unless File.directory?('tmp') 11 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 12 | FileUtils.chdir 'tmp/dpl_test' 13 | 14 | File.write 'config.ru', <<~STR 15 | require 'rack' 16 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 17 | STR 18 | 19 | run 'git add .' 20 | run "git commit -m 'test dpl Gleis #{ENV['ID']}'" 21 | -------------------------------------------------------------------------------- /.travis/providers/gleis/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.travis.gleis.app/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue StandardError => e 13 | puts e.message 14 | end 15 | 16 | 20.times do |i| 17 | actual = poll("#{url}?#{expected}_i#{i}") 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/gleis/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | install: true 4 | script: true 5 | 6 | before_deploy: 7 | - .travis/providers/gleis/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: gleis 12 | username: dpl-test@travis-ci.org 13 | password: 14 | secure: "PCqbKJQSrHguQecKbbO/RH30XpDoayedaHhjfBX3agot8liyLI4w0/EhUrkn9h8U0ZkNZaXEEROGzIQqnrU44YdTvKOcYUZrAanv6zw1GqBDp8o33s5FVn4otWOPmsQSOXa7WZLhsDroM4+OxZFFKerJXOrkyRkkRJht7kk6xTA=" 15 | app: dpl-test 16 | 17 | after_deploy: 18 | - cd ../.. 19 | - .travis/providers/gleis/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/hackage/delete: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'net/http' 4 | require 'uri' 5 | 6 | $stdout.sync = true 7 | 8 | url = 'http://hackage.haskell.org/package/dpl-test-0.0.0/candidate' 9 | id = ENV['ID'] 10 | 11 | def delete(url) 12 | puts "Deleting package candidate: #{url} ..." 13 | 14 | uri = URI.parse(url) 15 | http = Net::HTTP.new(uri.host, uri.port) 16 | req = Net::HTTP::Delete.new(uri.path) 17 | req.basic_auth('dpl_test', ENV['HACKAGE_PASSWORD']) 18 | res = http.request(req) 19 | 20 | if res.code == '303' 21 | puts 'Success' 22 | true 23 | else 24 | puts res.code 25 | # puts res.body 26 | false 27 | end 28 | end 29 | 30 | 10.times do 31 | exit 0 if delete(url) 32 | sleep 5 33 | end 34 | 35 | abort 'failed' 36 | -------------------------------------------------------------------------------- /.travis/providers/hackage/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl_test/library' 8 | chdir 'tmp/dpl_test' 9 | 10 | File.write 'dpl-test.cabal', <<~str 11 | name: dpl-test 12 | version: 0.0.0 13 | cabal-version: >=1.10 14 | build-type: Simple 15 | synopsis: Travis CI dpl test package 16 | description: Travis CI dpl test package. ID="#{ENV['ID']}" 17 | category: test 18 | license: MIT 19 | license-file: MIT.md 20 | copyright: 2015 Travis CI 21 | maintainer: Travis CI 22 | author: Travis CI 23 | 24 | library 25 | exposed-modules: DplTest 26 | hs-source-dirs: library 27 | default-language: Haskell2010 28 | str 29 | 30 | File.write 'library/DplTest.hs', <<~str 31 | module DplTest (module DplTest) where 32 | str 33 | 34 | File.write 'MIT.md', '' 35 | -------------------------------------------------------------------------------- /.travis/providers/hackage/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'net/http' 4 | require 'open-uri' 5 | 6 | $stdout.sync = true 7 | 8 | url = 'http://hackage.haskell.org/package/dpl-test-0.0.0/candidate' 9 | id = ENV['ID'] 10 | 11 | def exists?(url, expected) 12 | puts "Checking #{url} ..." 13 | html = URI.parse(url).read 14 | actual = html =~ /ID="(.*)"/ && $1 15 | puts "expected: #{expected}" 16 | puts "actual: #{actual}" 17 | expected == actual 18 | rescue OpenURI::HTTPError 19 | puts 'Not found' 20 | end 21 | 22 | 10.times do 23 | exit 0 if exists?(url, id) 24 | sleep 5 25 | end 26 | 27 | abort 'failed' 28 | -------------------------------------------------------------------------------- /.travis/providers/hackage/travis.yml: -------------------------------------------------------------------------------- 1 | language: haskell 2 | 3 | env: 4 | - secure: "VpE4HJ9rwvP2ARJhlvpuyrnD1cnDjMAPin+s60XqFjZXj6EHxehzynNkBOUNOgE4DhXDwjWA5ZwR72N/o1RF8w1zzt745zad5aj3LhvfBkol6f6nnwLBfx4ZtB3XWZx/ecYiZ8KFN/jaUVt59X8e3su7MWQQjIkTpr/yQiaFGBc=" 5 | 6 | install: true 7 | script: true 8 | 9 | before_deploy: 10 | - .travis/providers/hackage/prepare 11 | - cd tmp/dpl_test 12 | - cabal check 13 | 14 | deploy: 15 | - provider: hackage 16 | username: dpl_test 17 | password: 18 | secure: "bVOUfRs/zAd5PU0ompXNEhI/MPOaYYtL6VFLWGo2UfmpnW4qS55vdOQina/63GHV2J4IGef/IfvIhyvMt5pozs8QSv7b4L9LZuUcaw+TkzAERuT9AFy5yxqZhVaC4+3BhRSzkvYVKleOxea3D4QO+Jis7V6BaqzAb3fPIzdBZYc=" 19 | 20 | after_deploy: 21 | - cd ../../.travis/providers/hackage/ 22 | - ./test && ./delete || TRAVIS_TEST_RESULT=$? 23 | -------------------------------------------------------------------------------- /.travis/providers/hephy/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'rack' 3 | -------------------------------------------------------------------------------- /.travis/providers/hephy/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | rack (2.1.4) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | rack 11 | 12 | BUNDLED WITH 13 | 2.0.1 14 | -------------------------------------------------------------------------------- /.travis/providers/hephy/config.ru: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rack' 4 | app = ->(env) { [200, { 'Content-type' => 'text/plain' }, ['%{ID}']] } 5 | Rack::Handler::WEBrick.run(app, Host: '0.0.0.0', Port: '3000') 6 | -------------------------------------------------------------------------------- /.travis/providers/hephy/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'http://dpl-test.172.17.0.2.nip.io' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/hephy/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | services: 4 | - docker 5 | 6 | script: true 7 | 8 | before_deploy: 9 | - .travis/providers/hephy/prepare 10 | - export KUBECONFIG="$(kind get kubeconfig-path)" 11 | - kubectl cluster-info 12 | - cd tmp/dpl_test 13 | 14 | deploy: 15 | - provider: hephy 16 | controller: deis.172.17.0.2.nip.io 17 | username: dpl-user 18 | password: dpl-pass 19 | app: dpl-test 20 | 21 | after_deploy: 22 | - cd ../.. 23 | - .travis/providers/hephy/test || TRAVIS_TEST_RESULT=$? 24 | -------------------------------------------------------------------------------- /.travis/providers/heroku/api.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/heroku/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: heroku 12 | strategy: api 13 | app: dpl-test-heroku-api 14 | api_key: 15 | # Heroku API token from dpl-test@travis-ci.org 16 | # expires in June 2020, heroku authorizations:add to create a permanent one 17 | secure: "nnU3RBUg6cBo5TVWo8fnPiKI2R43a/gselqkSAR6btQgmy1OMmM9UM4EPEc1fcSa+OB0jX1aGqSRS4KRLEZBusr+ZewY+vtgM1c8kgSOZItYsYz8MizD/QtDE2iXSwUozuK5Jy2e9mnEPBLaU0W2DTnIEJLnAFN2LSodqf5efJI=" 18 | run: fail 19 | 20 | after_deploy: 21 | - cd ../.. 22 | - .travis/providers/heroku/test https://dpl-test-heroku-api.herokuapp.com/ || TRAVIS_TEST_RESULT=$? 23 | -------------------------------------------------------------------------------- /.travis/providers/heroku/git.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/heroku/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: heroku 12 | strategy: git 13 | app: dpl-test-heroku-git 14 | api_key: 15 | # Heroku API token from dpl-test@travis-ci.org 16 | # expires in June 2020, heroku authorizations:add to create a permanent one 17 | secure: "nnU3RBUg6cBo5TVWo8fnPiKI2R43a/gselqkSAR6btQgmy1OMmM9UM4EPEc1fcSa+OB0jX1aGqSRS4KRLEZBusr+ZewY+vtgM1c8kgSOZItYsYz8MizD/QtDE2iXSwUozuK5Jy2e9mnEPBLaU0W2DTnIEJLnAFN2LSodqf5efJI=" 18 | 19 | after_deploy: 20 | - cd ../.. 21 | - .travis/providers/heroku/test https://dpl-test-heroku-git.herokuapp.com/ || TRAVIS_TEST_RESULT=$? 22 | -------------------------------------------------------------------------------- /.travis/providers/heroku/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'Gemfile', <<~str 12 | source 'https://rubygems.org' 13 | ruby '2.6.3' 14 | gem 'rack' 15 | str 16 | 17 | File.write 'Gemfile.lock', <<~str 18 | GEM 19 | remote: https://rubygems.org/ 20 | specs: 21 | rack (2.0.7) 22 | 23 | PLATFORMS 24 | ruby 25 | 26 | DEPENDENCIES 27 | rack 28 | str 29 | 30 | File.write 'config.ru', <<~str 31 | require 'rack' 32 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 33 | str 34 | 35 | system 'git init' 36 | system 'git add .' 37 | system "git commit -m 'test dpl heroku #{Time.now}'" 38 | -------------------------------------------------------------------------------- /.travis/providers/heroku/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = ARGV[0] 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/netlify/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir_p 'tmp/dpl_test' 13 | chdir 'tmp/dpl_test' 14 | 15 | File.write 'index.html', ENV['ID'] 16 | -------------------------------------------------------------------------------- /.travis/providers/netlify/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | $stdout.sync = true 4 | 5 | require 'open-uri' 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.netlify.com' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | puts "polling: #{url} ..." 18 | actual = poll(url) 19 | puts "expected: #{expected.inspect}" 20 | puts "actual: #{actual.inspect}" 21 | exit 0 if actual == expected 22 | sleep 5 23 | end 24 | 25 | abort 'failed' 26 | -------------------------------------------------------------------------------- /.travis/providers/netlify/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 12 3 | 4 | install: true 5 | script: true 6 | 7 | before_deploy: 8 | - .travis/providers/netlify/prepare 9 | 10 | deploy: 11 | - provider: netlify 12 | 13 | site: 192d4997-a87a-4cce-9c00-899ddc073766 14 | auth: 15 | secure: "mLjntGlkBhuzIPd0GNZpCBFjEGv7YSPJx1NC1Tu4LWPshXWcLyvzIR3EDT0JCNlk9zrua/PZwv70nE/H19c6C7Gz+x2Qa8wp8WpUzx8/5w5u49XL4Mwxddz+bGXu1Pw8q9PhpGHJzGmnst0DXWhDEDUeHlB0KrrCPIJeA3TTmGQ=" 16 | dir: tmp/dpl_test 17 | prod: true 18 | 19 | after_deploy: 20 | - .travis/providers/netlify/test || TRAVIS_TEST_RESULT=$? 21 | -------------------------------------------------------------------------------- /.travis/providers/npm-github/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'package.json', <<~str 12 | { 13 | "name": "dpl_test", 14 | "repository": "git://github.com/travis-dpl-test/dpl_test", 15 | "description": "testing travis ci/dpl github npm integration", 16 | "version": "1.0.#{ENV['TRAVIS_BUILD_NUMBER']}-#{ENV['ID']}" 17 | } 18 | str 19 | -------------------------------------------------------------------------------- /.travis/providers/npm-github/query.graphql: -------------------------------------------------------------------------------- 1 | { 2 | user(login: "travis-dpl-test") { 3 | repository(name: "dpl_test") { 4 | registryPackages(name: "dpl_test", first: 1) { 5 | edges { 6 | node { 7 | latestVersion { 8 | version 9 | } 10 | } 11 | } 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.travis/providers/npm-github/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'net/http' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | 10 | def query 11 | File.read(File.expand_path('../query.graphql', __FILE__)) 12 | end 13 | 14 | def uri 15 | URI.parse('https://api.github.com/graphql') 16 | end 17 | 18 | def http 19 | http = Net::HTTP.new(uri.host, 443) 20 | http.use_ssl = true 21 | http 22 | end 23 | 24 | def request 25 | req = Net::HTTP::Post.new(uri.path) 26 | req['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" 27 | req['Accept'] = 'application/vnd.github.v3+json' 28 | req.body = JSON.dump(query: query) 29 | req 30 | end 31 | 32 | def response 33 | http.request(request) 34 | end 35 | 36 | def poll 37 | data = JSON.load(response.body) 38 | data['data']['user']['repository']['registryPackages']['edges'][0]['node']['latestVersion']['version'] 39 | rescue => e 40 | puts e.message 41 | end 42 | 43 | 10.times do 44 | actual = poll.to_s.split('-').last 45 | puts "expected: #{expected.inspect}" 46 | puts "actual: #{actual.inspect}" 47 | exit 0 if actual.include?(expected) 48 | sleep 5 49 | end 50 | 51 | abort 'failed' 52 | 53 | -------------------------------------------------------------------------------- /.travis/providers/npm-github/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | env: 4 | GITHUB_TOKEN: 5 | secure: "CdB9Js+GeDr7KTyZP+2bdra1OEKBa+Z5UwQ5g1bf0XjOyfsPt/Wxg4TpI8oPlh8KX3Gomn4Rbby/w8gPe5abi7YB9/EaEKc4Y9KV98JDUNYUTmhh9w3a0wgDss2D473+dK/65ABAAo8GYwm8+4fwBmtWVhChCbrFNwa10m4t3is=" 6 | 7 | script: 8 | - true 9 | 10 | before_deploy: 11 | - .travis/providers/npm-github/prepare 12 | 13 | deploy: 14 | - provider: npm 15 | registry: https://npm.pkg.github.com/@travis-dpl-test 16 | api_token: 17 | # personal access token with package registry scopes 18 | secure: "CdB9Js+GeDr7KTyZP+2bdra1OEKBa+Z5UwQ5g1bf0XjOyfsPt/Wxg4TpI8oPlh8KX3Gomn4Rbby/w8gPe5abi7YB9/EaEKc4Y9KV98JDUNYUTmhh9w3a0wgDss2D473+dK/65ABAAo8GYwm8+4fwBmtWVhChCbrFNwa10m4t3is=" 19 | access: public 20 | src: tmp/dpl_test 21 | 22 | after_deploy: 23 | - .travis/providers/npm-github/test || TRAVIS_TEST_RESULT=$? 24 | -------------------------------------------------------------------------------- /.travis/providers/npm-myget/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'package.json', <<~str 12 | { 13 | "name": "@dpl-test/dpl-test", 14 | "description": "testing travis ci/dpl npm integration", 15 | "version": "1.0.0-#{ENV['ID']}" 16 | } 17 | str 18 | -------------------------------------------------------------------------------- /.travis/providers/npm-myget/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = "https://www.myget.org/F/dpl-test/npm/@dpl-test/dpl-test/-/@dpl-test/dpl-test-1.0.0-#{ENV['ID']}.tgz" 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | puts "Checking #{url}" 19 | exit 0 if poll(url) 20 | sleep 5 21 | end 22 | 23 | abort 'failed' 24 | -------------------------------------------------------------------------------- /.travis/providers/npm-myget/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/npm-myget/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: npm 12 | registry: https://www.myget.org/F/dpl-test/npm/ 13 | api_token: 14 | secure: "RJKzq+WIewvXSvU2mTeqDn9eIM7Vq3fAvXrCdHjMGbl301ilq9IzUWhea1UJfcP0WbbF6h7oS6jl3DMKLok9Bi6A7XmT1zd3KVP5ZE8FeKVqGGS7hLk6JtymJPpVudWOb+bhcEzox52g95NHFB8/H1VFr8fSBf89NzFI7QIjBaw=" 15 | access: public 16 | 17 | after_deploy: 18 | - cd ../.. 19 | - .travis/providers/npm-myget/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/npm/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'package.json', <<~str 12 | { 13 | "name": "@dpl-test/dpl-test", 14 | "description": "testing travis ci/dpl npm integration", 15 | "version": "1.0.0-#{ENV['ID']}" 16 | } 17 | str 18 | -------------------------------------------------------------------------------- /.travis/providers/npm/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = 'https://registry.npmjs.com/@dpl-test/dpl-test' 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | puts "Checking #{url}" 19 | data = JSON.load(poll(url)) 20 | actual = data['versions'].keys.map { |key| key.split('-').last } 21 | puts "expected: #{expected.inspect}" 22 | puts "actual: #{actual.inspect}" 23 | exit 0 if actual.include?(expected) 24 | sleep 5 25 | end 26 | 27 | abort 'failed' 28 | -------------------------------------------------------------------------------- /.travis/providers/npm/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/npm/prepare 8 | - cd tmp/dpl_test 9 | 10 | deploy: 11 | - provider: npm 12 | email: dpl-test@travis-ci.org 13 | api_token: 14 | secure: "cvaSdHFNK//eo1fkI4WKMxAd9L+8kaflwbfaOACnDclt+5iqcOAZ4Rn/x9Ook4DdPg6oahiSqWDwTcnCO/K58BiJkB2jXzdFBsjDUIQfqvI2hpnFnzuUxRi0Q3Smo2NgwZezej5Q7g5zqSRRYVTHiF3eGaQPw8kKM3cE9WaGe8c=" 15 | access: public 16 | 17 | after_deploy: 18 | - cd ../.. 19 | - .travis/providers/npm/test || TRAVIS_TEST_RESULT=$? 20 | -------------------------------------------------------------------------------- /.travis/providers/nuget-myget/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'dpl-test.csproj', <<~str 12 | 13 | 14 | netstandard2.0 15 | 1.0.0-#{ENV['ID']} 16 | 17 | 18 | str 19 | 20 | system 'dotnet pack -o ./' 21 | -------------------------------------------------------------------------------- /.travis/providers/nuget-myget/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = "https://www.myget.org/F/dpl-nuget-test/api/v2/package/dpl-test/1.0.0-#{ENV['ID']}" 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | puts "Checking #{url}" 19 | exit 0 if poll(url) 20 | sleep 5 21 | end 22 | 23 | abort 'failed' 24 | -------------------------------------------------------------------------------- /.travis/providers/nuget-myget/travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | mono: none 3 | dotnet: 2.1.502 4 | 5 | script: 6 | - true 7 | 8 | before_deploy: 9 | - .travis/providers/nuget-myget/prepare 10 | - cd tmp/dpl_test 11 | 12 | deploy: 13 | - provider: nuget 14 | registry: https://www.myget.org/F/dpl-nuget-test/api/v2/package 15 | api_key: 16 | secure: "o7/D199WZFJgyJNg+PW+dLOqV/3V2/1/BUF+3cLTudllzUbGyudeJNNXd7iYWRXT42t6Q3TRTGK3JCK4kCVodPDmawPpRJik54fJ/b+x5m9tz682Isw1qeg4fIQB8D1UsUevd1HHPHsqOgXtrPRcvhYWW7AbOCSNsLuES8LKdLY=" 17 | 18 | after_deploy: 19 | - cd ../.. 20 | - .travis/providers/nuget-myget/test || TRAVIS_TEST_RESULT=$? 21 | -------------------------------------------------------------------------------- /.travis/providers/openshift/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | netrc = File.expand_path('~/.netrc') 13 | 14 | File.write netrc, <<~str 15 | machine github.com 16 | login #{ENV['GITHUB_TOKEN']} 17 | str 18 | File.chmod 0600, netrc 19 | 20 | mkdir 'tmp' unless File.directory?('tmp') 21 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 22 | chdir 'tmp/dpl_test' 23 | run 'git checkout -B openshift' 24 | 25 | File.write 'config.ru', <<~str 26 | require 'rack' 27 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 28 | str 29 | 30 | File.write 'id', ENV['ID'] 31 | 32 | run 'git add .' 33 | run "git commit -m 'test dpl openshift #{ENV['ID']}'" 34 | run 'git push -f origin openshift' 35 | -------------------------------------------------------------------------------- /.travis/providers/openshift/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'http://dpl-test-app-dpl-test.apps.us-west-2.online-starter.openshift.com/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/openshift/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | env: 4 | # GITHUB_TOKEN=[personal access token with repo scope on travis-dpl-test] 5 | secure: "o7IxUSrMNTYoVqWO+LkmGn3wccPEEi9CewntdP/KGgH1g8YdDuEjZvSmSlNacEsXfibz+F3pWM1aNb3Qx5Is0fQizm0eVaAXs/4qwPZOyByzOt5QdO0PXw4BRuojc6kByW0QcsbUceyxUSFNQeWernpinlZAnblpLBjTpqbPKSw=" 6 | 7 | install: true 8 | script: true 9 | 10 | before_deploy: 11 | - .travis/providers/openshift/prepare 12 | - export TRAVIS_COMMIT=$(GIT_DIR=tmp/dpl_test/.git git rev-parse HEAD | tr -d '\n') 13 | - cd tmp/dpl_test 14 | 15 | deploy: 16 | - provider: openshift 17 | server: https://api.us-west-2.online-starter.openshift.com:6443 18 | project: dpl-test 19 | app: dpl-test-app 20 | token: 21 | secure: "ow46ArHZy2lQWdTCMz7zxmxGD6Jrgokw8DR0mNBLPl5kUSgq7x4LNI0SI5r/iS1Nus8cFe5JPQvgX/niYfPYplF4fNR42aRw3Who2OjaA98eeYqbkExP6nV48h5LGEOF8wgzVSgxUCO8SGduQqmjcJUwW30mOmmA1VUa8DFhgs0=" 22 | 23 | after_deploy: 24 | - cd ../.. 25 | - .travis/providers/openshift/test || TRAVIS_TEST_RESULT=$? 26 | # - ./oc scale rc --replicas=0 --all 27 | # - ./oc delete pod --all 28 | -------------------------------------------------------------------------------- /.travis/providers/packagecloud/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system cmd 10 | abort "#{cmd} failed" unless $?.exitstatus == 0 11 | end 12 | 13 | def file(path, content) 14 | puts "Writing file #{path}" 15 | mkdir_p(File.dirname(path)) 16 | File.write(path, content) 17 | end 18 | 19 | def cd(dir) 20 | mkdir_p(dir) unless dir == '..' 21 | chdir(dir) 22 | end 23 | 24 | cd 'tmp/dpl_test' 25 | 26 | file 'lib/dpl/test.rb', <<~str 27 | module Dpl 28 | module Test 29 | extend self 30 | def test 31 | puts ENV['ID'] 32 | end 33 | end 34 | end 35 | str 36 | 37 | file 'dpl_test.gemspec', <<~str 38 | Gem::Specification.new do |s| 39 | s.name = 'dpl_test' 40 | s.version = "0.0.#{ENV['TRAVIS_BUILD_NUMBER']}.dev-#{ENV['ID']}" 41 | s.licenses = ['MIT'] 42 | s.summary = "This is dpl_test" 43 | s.description = "This is dpl_test." 44 | s.authors = ["Travis CI Dpl"] 45 | s.email = 'contact@travis-ci.com' 46 | s.homepage = 'https://github.org/travis-ci/dpl' 47 | s.files = ["lib/dpl/test.rb"] 48 | end 49 | str 50 | 51 | run 'gem build dpl_test.gemspec' 52 | -------------------------------------------------------------------------------- /.travis/providers/packagecloud/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = "https://packagecloud.io/api/v1/repos/dpl-test/dpl-test/package/gem/dpl_test/0.0.#{ENV['TRAVIS_BUILD_NUMBER']}.dev.pre.#{ENV['ID']}.json" 10 | 11 | def poll(url) 12 | URI.parse(url).read(http_basic_authentication: [ENV['PACKAGECLOUD_TOKEN'], '']) 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | puts "Checking #{url}" 19 | data = JSON.load(poll(url)) 20 | actual = data['version'].split('.').last 21 | puts "expected: #{expected.inspect}" 22 | puts "actual: #{actual.inspect}" 23 | exit 0 if actual == expected 24 | sleep 5 25 | end 26 | 27 | abort 'failed' 28 | -------------------------------------------------------------------------------- /.travis/providers/packagecloud/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | env: 4 | - secure: "ndun8GB7oj0YOcRLb9C+gSXTSNBJMpNV6kb+jrwyoDZxcrye0XQt/r5LqaVjovbVHA1EulNICoFmOS/nK3xGjTrjlmFUPLvmiQGvSYDxzdwKOROCQ5eJcQNP3tZzuLKxuAZa69qTho0A0WcSdD/HgJ1+4iRuDzx3OSaoqZcmJkE=" 5 | 6 | script: 7 | - true 8 | 9 | before_deploy: 10 | - .travis/providers/packagecloud/prepare 11 | 12 | deploy: 13 | - provider: packagecloud 14 | 15 | username: dpl-test 16 | repository: dpl-test 17 | token: 18 | secure: "KM+8hKLSHGV1q+R5n5/mHcvEs9WjgPRb9h53wHFuvNTH7qXjuhNRqLvjRB5KJU/yh8JoErZ8AoqTOT1EJ5ma6E72w20+rFK6OD1fgV0E1rfFoX32ip2zVsikoAdQDjmcGzYC/lDIx/Ezw1iGi2xf6CO905dZNpTRSva9KLBSSXU=" 19 | local_dir: tmp/dpl_test 20 | dist: node 21 | 22 | after_deploy: 23 | - .travis/providers/packagecloud/test || TRAVIS_TEST_RESULT=$? 24 | -------------------------------------------------------------------------------- /.travis/providers/puppetforge/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir 10 | 11 | File.write 'metadata.json', <<~str 12 | { 13 | "name": "dpltest-test", 14 | "version": "0.0.0-test.#{ENV['ID']}", 15 | "author": "Dpl Test", 16 | "summary": "Dpl Test Module", 17 | "license": "MIT", 18 | "source": "https://github.com/travis-ci/dpl", 19 | "dependencies": [ 20 | { 21 | "name":"puppetlabs-stdlib", 22 | "version_requirement":">= 1.0.0" 23 | } 24 | ] 25 | } 26 | str 27 | 28 | cmd = '$ puppet module build' 29 | puts cmd 30 | system cmd 31 | 32 | -------------------------------------------------------------------------------- /.travis/providers/puppetforge/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = "0.0.0-test.#{ENV['ID']}" 9 | url = "https://forgeapi.puppet.com/v3/releases/dpltest-test-#{expected}" 10 | 11 | def poll(url) 12 | puts "Checking #{url}" 13 | uri = URI.parse(url) 14 | data = JSON.load(uri) 15 | data['version'] 16 | rescue => e 17 | puts e.message 18 | nil 19 | end 20 | 21 | 10.times do 22 | actual = poll(url) 23 | puts "expected: #{expected.inspect}" 24 | puts "actual: #{actual.inspect}" 25 | exit 0 if actual == expected 26 | sleep 5 27 | end 28 | 29 | abort 'failed' 30 | -------------------------------------------------------------------------------- /.travis/providers/puppetforge/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - gem install puppet 8 | - .travis/providers/puppetforge/prepare 9 | - cd tmp/dpl_test 10 | 11 | deploy: 12 | - provider: puppetforge 13 | 14 | username: dpltest 15 | password: 16 | secure: "HKQfOdPKG6lOWM0cdD3tSq2i93uNRFFH8xYDISsoJ7uftngqU9nKvCWGDtI54Wxfj6eDzadqA0Apm4OnhWaAsXkxUD1BfbaO+ceonK8Ye09iKRfP9kgPW4Owqq/EUmOEfvqXELO+rtJDKlXZl2WnHK3Isq2tvHxcqMMgdKHVkL8=" 17 | 18 | after_deploy: 19 | - cd ../.. 20 | - .travis/providers/puppetforge/test || TRAVIS_TEST_RESULT=$? 21 | -------------------------------------------------------------------------------- /.travis/providers/pypi/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl-test/dpl-test' 8 | chdir 'tmp/dpl-test' 9 | 10 | File.write 'dpl-test/__init__.py', <<~str 11 | def test(): 12 | return ('test') 13 | str 14 | 15 | File.write 'setup.py', <<~str 16 | from setuptools import setup 17 | 18 | setup(name='dpl-test', 19 | version='#{ENV['DPL_TEST_VERSION']}', 20 | description='Testing Travis CI dpl PyPI integration', 21 | url='http://github.com/travis-ci/dpl', 22 | author='Travis CI', 23 | author_email='contact@travis-ci.org', 24 | license='MIT', 25 | packages=['dpl-test'], 26 | zip_safe=False) 27 | str 28 | -------------------------------------------------------------------------------- /.travis/providers/pypi/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['DPL_TEST_VERSION'] 9 | url = 'https://test.pypi.org/pypi/dpl-test/json' 10 | 11 | def poll(url) 12 | data = JSON.load(URI.parse(url).read) 13 | data['releases'].keys.map { |key| key.split('-').last } 14 | rescue => e 15 | puts e.message 16 | end 17 | 18 | 10.times do 19 | puts "Checking #{url}" 20 | uri = URI.parse(url) 21 | actual = poll(url) 22 | puts "expected: #{expected.inspect}" 23 | puts "actual: #{actual.inspect}" 24 | exit 0 if actual.include?(expected) 25 | sleep 5 26 | end 27 | 28 | abort 'failed' 29 | -------------------------------------------------------------------------------- /.travis/providers/pypi/travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: python 3 | python: 3.6 4 | 5 | script: 6 | - true 7 | 8 | before_deploy: 9 | - export DPL_TEST_VERSION=$(curl -s https://test.pypi.org/pypi/dpl-test/json | jq -r '.info | .version' | ruby -e 'v = $stdin.read.chomp.split("."); v = %w(0 0 0) if v.empty?; v[2] = v[2].to_i + 1; puts v.join(".")') 10 | - .travis/providers/pypi/prepare 11 | - cd tmp/dpl-test 12 | 13 | deploy: 14 | - provider: pypi 15 | username: dpl-test 16 | password: 17 | secure: "SGbyj5bmjkckk7K7FSnL+oZlmEgRylebE8WEtnOffv0r/c90hf+yPZHX8wpbxFOECfQrAMsGgN53q+DQfIbuA6KTNPWBegXrQWN0ehWYZWCUr1vMOrYb5dN/vepMEcfj4c+cRZohw8rubJFlGVxAXJGVcjZ6F+c1kzRxHXY9lLU=" 18 | server: https://test.pypi.org/legacy/ 19 | 20 | after_deploy: 21 | - cd ../.. 22 | - .travis/providers/pypi/test || TRAVIS_TEST_RESULT=$? 23 | -------------------------------------------------------------------------------- /.travis/providers/rubygems/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system cmd 10 | abort "#{cmd} failed" unless $?.exitstatus == 0 11 | end 12 | 13 | def file(path, content) 14 | puts "Writing file #{path}" 15 | mkdir_p(File.dirname(path)) 16 | File.write(path, content) 17 | end 18 | 19 | def cd(dir) 20 | mkdir_p(dir) unless dir == '..' 21 | chdir(dir) 22 | end 23 | 24 | cd 'tmp/dpl_test_rubygems' 25 | 26 | file 'bin/dpl_test', <<~str 27 | #!/usr/bin/env ruby 28 | $: << File.expand_path('../../lib', __FILE__) 29 | 30 | require 'dpl/test' 31 | Dpl::Test.test 32 | str 33 | 34 | chmod '+x', 'bin/dpl_test' 35 | 36 | file 'lib/dpl/test.rb', <<~str 37 | module Dpl 38 | module Test 39 | extend self 40 | def test 41 | puts ENV['ID'] 42 | end 43 | end 44 | end 45 | str 46 | 47 | file 'dpl_test.gemspec', <<~str 48 | Gem::Specification.new do |s| 49 | s.name = 'dpl_test' 50 | s.version = '0.0.1' 51 | s.licenses = ['MIT'] 52 | s.summary = "This is dpl_test" 53 | s.description = "This is dpl_test." 54 | s.authors = ["Travis CI Dpl"] 55 | s.email = 'contact@travis-ci.com' 56 | s.homepage = 'https://github.org/travis-ci/dpl' 57 | s.executables = ['dpl_test'] 58 | s.files = ["lib/dpl/test.rb"] 59 | end 60 | str 61 | 62 | file 'config.ru', <<~str 63 | require 'geminabox' 64 | Gem::ConfigFile # force autoload? 65 | run Geminabox::Server 66 | str 67 | 68 | run 'gem install geminabox' 69 | run 'rackup' 70 | -------------------------------------------------------------------------------- /.travis/providers/rubygems/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'net/http' 4 | require 'uri' 5 | 6 | # not sure why, but strangely, this doesn't list the gem, as it would, locally 7 | # puts Net::HTTP.get(URI.parse('http://localhost:9292/')) 8 | 9 | $stdout.sync = true 10 | 11 | url = 'http://localhost:9292/gems/dpl_test' 12 | 13 | def poll(url) 14 | uri = URI.parse(url) 15 | http = Net::HTTP.new(uri.host, uri.port) 16 | req = Net::HTTP::Get.new(uri.path) 17 | res = http.request(req) 18 | res.code 19 | rescue => e 20 | puts e.message 21 | end 22 | 23 | 24 | 5.times do 25 | status = poll(url) 26 | puts 'GET http://localhost:9292/gems/dpl_test' 27 | puts "Status: #{status}" 28 | exit 0 if status.to_i == 200 29 | sleep 3 30 | end 31 | 32 | abort 'failed' 33 | -------------------------------------------------------------------------------- /.travis/providers/rubygems/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | - true 5 | 6 | before_deploy: 7 | - .travis/providers/rubygems/prepare& 8 | - while ! curl -s http://localhost:9292 >/dev/null; do sleep 1; done 9 | - cd tmp/dpl_test_rubygems 10 | 11 | deploy: 12 | - provider: rubygems 13 | username: 14 | # the string username 15 | secure: "XGeKKoJAMCH88Es5PvfY/+WW8KneG+fsygOyj0ov+RuJkIlcm44mES6scM8yCXPYecVX6gDPaIegz63g0VDVgM+uGN5/z9UKO2q7t39R+r7APml2CT1hq21zWcF6SsaM+kEwzuK4COy0RsLxOG0fX+wankEUes2n15UBSfasp2s=" 16 | password: 17 | # the string password 18 | secure: "HNromDkeUbrKu+uvYt3SOQ/OCB//A2oxvlRudU1ECuh+5lyyLnXLR6vVxbAEUc7GNNNQp722lyV9Ni4y1GroIDGH7ysviA3u1cUaY8d1PHs3/xBxjgOnNcvnz4d4LUWIEhdELpacLPqe1U0H+EmfbyxV3EZ7Xo8IU7QrEMQyytw=" 19 | gem: dpl_test 20 | gemspec_glob: ./dpl_*.gemspec 21 | host: http://localhost:9292 22 | 23 | after_deploy: 24 | - cd ../.. && .travis/providers/rubygems/test || TRAVIS_TEST_RESULT=$? 25 | -------------------------------------------------------------------------------- /.travis/providers/scalingo/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | def run(cmd) 8 | puts "$ #{cmd}" 9 | system(cmd) || abort 10 | end 11 | 12 | mkdir 'tmp' unless File.directory?('tmp') 13 | run 'git clone https://github.com/travis-ci/dpl_test.git tmp/dpl_test' 14 | chdir 'tmp/dpl_test' 15 | 16 | File.write 'config.ru', <<~str 17 | require 'rack' 18 | run ->(env) { [200, { 'Content-type' => 'text/plain' }, ['#{ENV['ID']}']] } 19 | str 20 | 21 | run 'git add .' 22 | run "git commit -m 'test dpl scalingo #{ENV['ID']}'" 23 | -------------------------------------------------------------------------------- /.travis/providers/scalingo/scale: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'json' 4 | require 'net/http' 5 | 6 | def bearer_token 7 | uri = URI.parse("https://auth.scalingo.com/v1/tokens/exchange") 8 | http = Net::HTTP.new(uri.host, 443) 9 | http.use_ssl = true 10 | req = Net::HTTP::Post.new(uri.path) 11 | req.basic_auth('', ENV['SCALINGO_TOKEN']) 12 | res = http.request(req) 13 | JSON.parse(res.body)['token'] 14 | end 15 | 16 | def scale(count) 17 | uri = URI.parse("https://api.scalingo.com/v1/apps/dpl-test/scale") 18 | http = Net::HTTP.new(uri.host, 443) 19 | http.use_ssl = true 20 | req = Net::HTTP::Post.new(uri.path) 21 | req['Authorization'] = "Bearer #{bearer_token}" 22 | req['Content-Type'] = 'application/json' 23 | req.body = JSON.dump(containers: [name: 'web', amount: count, size: 'S']) 24 | res = http.request(req) 25 | end 26 | 27 | scale(ARGV[0].to_i) 28 | 29 | -------------------------------------------------------------------------------- /.travis/providers/scalingo/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | 5 | $stdout.sync = true 6 | 7 | expected = ENV['ID'] 8 | url = 'https://dpl-test.scalingo.io/' 9 | 10 | def poll(url) 11 | URI.parse(url).read 12 | rescue => e 13 | puts e.message 14 | end 15 | 16 | 20.times do 17 | actual = poll(url) 18 | puts "expected: #{expected.inspect}" 19 | puts "actual: #{actual.inspect}" 20 | exit 0 if actual == expected 21 | sleep 5 22 | end 23 | 24 | abort 'failed' 25 | -------------------------------------------------------------------------------- /.travis/providers/scalingo/travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | env: 4 | # SCALINGO_TOKEN=[scalingo api token] 5 | secure: "JjRCTqCz5+s6jMKd6LLlldp/79kzdzEUGcfOKLDD16iLMpuDXeMa4M0rxtbICJs79eC68E0NLOrpwF96pzZCv74wTNzTJeUh15+NBErBBafkBijnoML/2Xp0K+ybAs8b2IrJ8RgH+oYyf5mQXz5Qq9PRp/lquRMIyb7TjGU4A54=" 6 | 7 | install: true 8 | script: true 9 | 10 | before_deploy: 11 | - .travis/providers/scalingo/scale 1 12 | - .travis/providers/scalingo/prepare 13 | - cd tmp/dpl_test 14 | 15 | deploy: 16 | - provider: scalingo 17 | app: dpl-test 18 | api_token: 19 | secure: "Gtk9nEqjD8meGWVBB2oH7VGy4dFyQh9GmhICRWBXa2YNxQy98bikuXTPoDQJ395S4hWATLR1TWvp/rZ4H59GcOnyp8GuF9/O25DcLvZ1H0WCW75WckkpBPF8YEElVQlC17LmC3zAVG7qtp1QnmawhWXxJX7PL1B97tuqwXhVlcI=" 20 | 21 | after_deploy: 22 | - cd ../.. 23 | - .travis/providers/scalingo/test || TRAVIS_TEST_RESULT=$? 24 | - .travis/providers/scalingo/scale 0 25 | -------------------------------------------------------------------------------- /.travis/providers/snap/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dee-pee-ell-test/snap' 8 | mkdir_p 'tmp/dee-pee-ell-test/bin' 9 | chdir 'tmp/dee-pee-ell-test' 10 | 11 | File.write 'bin/dee-pee-ell-test', <<~str 12 | #!/bin/bash 13 | echo -n "This is just a test: #{ENV['ID']}" 14 | str 15 | 16 | FileUtils.chmod 0755, "bin/dee-pee-ell-test" 17 | 18 | File.write 'snap/snapcraft.yaml', <<~str 19 | name: dee-pee-ell-test 20 | version: "#{ENV['ID']}" 21 | summary: Travis CI dpl canary test snap 22 | description: Travis CI dpl canary test snap. 23 | base: core18 24 | confinement: strict 25 | grade: stable 26 | 27 | apps: 28 | dee-pee-ell-test: 29 | command: bin/dee-pee-ell-test 30 | 31 | parts: 32 | dee-pee-ell-test: 33 | plugin: dump 34 | source: . 35 | str 36 | 37 | cmd = 'sudo snapcraft snap --use-lxd' 38 | puts cmd 39 | system cmd 40 | -------------------------------------------------------------------------------- /.travis/providers/snap/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = "This is just a test: #{ENV['ID']}" 9 | actual = %x[dee-pee-ell-test] 10 | 11 | exit 0 if actual == expected 12 | 13 | abort 'failed' 14 | -------------------------------------------------------------------------------- /.travis/providers/snap/travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: shell 3 | 4 | script: 5 | - true 6 | 7 | addons: 8 | snaps: 9 | - name: snapcraft 10 | channel: stable 11 | confinement: classic 12 | - name: lxd 13 | channel: stable 14 | 15 | before_deploy: 16 | - sudo /snap/bin/lxd.migrate -yes 17 | - sudo /snap/bin/lxd waitready 18 | - sudo /snap/bin/lxd init --auto 19 | - .travis/providers/snap/prepare 20 | 21 | deploy: 22 | - provider: snap 23 | snap: '**/dee-pee-ell-test_*.snap' 24 | channel: edge 25 | 26 | after_deploy: 27 | - sudo snap install dee-pee-ell-test --edge 28 | - .travis/providers/snap/test || TRAVIS_TEST_RESULT=$? 29 | -------------------------------------------------------------------------------- /.travis/providers/surge/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | dir = 'tmp/dpl_test' 8 | mkdir_p dir 9 | chdir dir do 10 | File.write 'index.html', ENV['ID'] 11 | end 12 | -------------------------------------------------------------------------------- /.travis/providers/surge/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | url = 'https://travis-ci-dpl-test.surge.sh/index.html' 10 | 11 | def poll(url) 12 | URI.parse(url).read 13 | rescue => e 14 | puts e.message 15 | end 16 | 17 | 10.times do 18 | actual = poll(url) 19 | puts "expected: #{expected.inspect}" 20 | puts "actual: #{actual.inspect}" 21 | exit 0 if actual == expected 22 | sleep 5 23 | end 24 | 25 | abort 'failed' 26 | -------------------------------------------------------------------------------- /.travis/providers/surge/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 11 3 | 4 | script: 5 | - true 6 | 7 | before_deploy: 8 | - .travis/providers/surge/prepare 9 | 10 | deploy: 11 | - provider: surge 12 | login: 13 | dpl-test@travis-ci.org 14 | token: 15 | # travis encrypt [surge token from `surge token`] 16 | secure: "q7S5tf3vVoT8UEGWetIKvb+Nd2iAhFtDA3lfYSL1xOV3ZxIVhOgl18xLDHSfu8zAZ0kbcdrVy6I6+/ZGEYqgBAtjBth6DaUlvDv7Xqw+E/Ad7vTJyR7VE2gW07Gs5Ear3bN6ty3PKMaysjO7NXhqfSACWvBK1+DDdpLJ4eW2qAQ=" 17 | project: ./tmp/dpl_test 18 | domain: travis-ci-dpl-test.surge.sh 19 | 20 | after_deploy: 21 | - .travis/providers/surge/test || TRAVIS_TEST_RESULT=$? 22 | -------------------------------------------------------------------------------- /.travis/providers/testfairy/prepare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp/dpl_test 4 | cp .travis/providers/testfairy/testfairy.apk tmp/dpl_test/${ID}.apk -------------------------------------------------------------------------------- /.travis/providers/testfairy/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'json' 4 | require 'open-uri' 5 | require 'base64' 6 | 7 | $stdout.sync = true 8 | 9 | expected = ENV['ID'] 10 | url = 'https://api.testfairy.com/api/1/projects/6820850/builds' 11 | auth = Base64.strict_encode64('travis-dpl-tests@testfairy.com' + ':' + ENV['TESTFAIRY_API_KEY']) 12 | 13 | def poll(url, headers) 14 | uri = URI.parse(url) 15 | data = JSON.parse(uri.read(headers)) 16 | filename = File.basename(data['builds'][0]['appUrl']) 17 | filename.sub('.apk', '') 18 | rescue => e 19 | puts e.message 20 | end 21 | 22 | 40.times do 23 | actual = poll(url, 'Authorization' => "Basic #{auth}") 24 | puts "expected: #{expected.inspect}" 25 | puts "actual: #{actual.inspect}" 26 | exit 0 if actual == expected 27 | sleep 5 28 | end 29 | 30 | abort 'failed' 31 | -------------------------------------------------------------------------------- /.travis/providers/testfairy/testfairy.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/travis-ci/dpl/8c6eabc699178e992236adf4472f1753b7b292ce/.travis/providers/testfairy/testfairy.apk -------------------------------------------------------------------------------- /.travis/providers/testfairy/travis.yml: -------------------------------------------------------------------------------- 1 | language: shell 2 | 3 | script: 4 | true 5 | 6 | env: 7 | - secure: "KbgeC+baSQKcldV2TPC6C295LB2ufaReuC5Wcx/r+pSwesXNG15phNltwZL9TjptxPxgllbC4LncopL8vBkh9tvrNLkBvXFeVu4meHRW6opFeHSjsaQOQr0zwcAJiUt5Pp4R+E5XbiIbFpZKUU6vY5oeyIEt45MhyxjciKYAUUI=" 8 | 9 | before_deploy: 10 | - .travis/providers/testfairy/prepare 11 | 12 | deploy: 13 | - provider: testfairy 14 | api_key: ${TESTFAIRY_API_KEY} 15 | app_file: tmp/dpl_test/${ID}.apk 16 | 17 | after_deploy: 18 | - .travis/providers/testfairy/test || TRAVIS_TEST_RESULT=$? 19 | -------------------------------------------------------------------------------- /.travis/providers/transifex/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fileutils' 4 | 5 | include FileUtils 6 | 7 | mkdir_p 'tmp/dpl_test' 8 | chdir 'tmp/dpl_test' 9 | 10 | mkdir '.tx' 11 | mkdir 'locales' 12 | 13 | File.write '.tx/config', <<~str 14 | [main] 15 | host = https://www.transifex.com 16 | 17 | [dpl_test.test] 18 | file_filter = locales/.json 19 | source_file = locales/en.json 20 | source_lang = en 21 | type = KEYVALUEJSON 22 | str 23 | 24 | File.write 'locales/en.json', <<~str 25 | { 26 | "test": "#{ENV['ID']}" 27 | } 28 | str 29 | -------------------------------------------------------------------------------- /.travis/providers/transifex/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'open-uri' 4 | require 'json' 5 | 6 | $stdout.sync = true 7 | 8 | expected = ENV['ID'] 9 | 10 | def poll 11 | uri = URI.parse('https://www.transifex.com/api/2/project/dpl_test/resource/test/translation/en/?mode=default&file') 12 | puts "polling #{uri.to_s} ..." 13 | json = uri.read(http_basic_authentication: ['dpl_test', ENV['TRANSIFEX_PASSWORD']]) 14 | data = JSON.parse(json) 15 | data['test'] 16 | rescue => e 17 | puts e.message 18 | end 19 | 20 | 20.times do 21 | actual = poll 22 | puts "expected: #{expected.inspect}" 23 | puts "actual: #{actual.inspect}" 24 | exit 0 if actual == expected 25 | sleep 5 26 | end 27 | 28 | abort 'failed' 29 | -------------------------------------------------------------------------------- /.travis/providers/transifex/travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 2.7 3 | 4 | env: 5 | # TRANSIFEX_PASSWORD=[password] 6 | secure: "UfTXhgrmPYL4rGhpS7Y3FWoD4kNbrMqqd5szf5Dl0gDAPIT6c3N+Y1V13swLQUID1maGdM0Lp2HLX9g+9v9nHLSJAI49QPzJtt+vWnav1qV2sZ1CZZuLWWfD8UcYqaYoDMpy7JYOd5ufTLCQFDAKkaLTgTBIaXtrDWN1KT1RCjA=" 7 | 8 | install: true 9 | script: true 10 | 11 | before_deploy: 12 | - .travis/providers/transifex/prepare 13 | - cd tmp/dpl_test 14 | - python --version 15 | 16 | deploy: 17 | - provider: transifex 18 | username: 19 | dpl_test 20 | password: 21 | secure: "YcD1Dh+mdRLMbCZ8dWoP61nM0wjHp5mALspIqACKltZ4Rx/+2DEWfmbX+8haNtNi5/dsfxrsh1dSygpLBVMd6EJYcXgrw0fya8QCAeobM559WUZXgHkx641xr16yTpoGRDpkO5yM3DUVGWqAjTrUFEHVeQ/Gnlx98D7aS/azBQQ=" 22 | 23 | after_deploy: 24 | - cd ../.. 25 | - .travis/providers/transifex/test || TRAVIS_TEST_RESULT=$? 26 | -------------------------------------------------------------------------------- /.travis/test_install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This tests installing runtime dependencies for all providers, as part of 4 | # a second stage in .travis.yml. 5 | 6 | $: << 'lib' 7 | 8 | require 'dpl' 9 | 10 | def opts_for(provider) 11 | opts = provider.opts.select(&:required?) 12 | opts = opts + [provider.opts[provider.required.map(&:first).first]].compact 13 | opts.map { |opt| opt_for(opt) }.join(' ') 14 | end 15 | 16 | def opt_for(opt) 17 | "--#{opt.name} #{opt.enum? ? opt.enum.first : 'str'}" 18 | end 19 | 20 | def run(cmd) 21 | puts 22 | puts cmd 23 | fail unless system cmd 24 | end 25 | 26 | skip = %i(help heroku pages provider) 27 | keys = Dpl::Provider.registry.keys.sort - skip 28 | providers = keys.map { |key| Dpl::Provider[key] } 29 | 30 | providers.each do |provider| 31 | run "bin/dpl #{provider.registry_key} --stage install #{opts_for(provider)}" 32 | # run 'gem list' 33 | end 34 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $LOAD_PATH << 'lib' 4 | require 'dpl/support/gems' 5 | 6 | source 'https://rubygems.org' 7 | ruby '>= 3' 8 | 9 | gemspec name: 'dpl' 10 | # gem 'travis-cl' 11 | # gem 'travis-packagecloud-ruby' 12 | # gem 'json_pure', '~> 2.6' 13 | 14 | # gem 'regstry', path: '../../registry' 15 | 16 | gems = Dpl::Support::Gems.new('lib/dpl/providers/**/*.rb') 17 | gems.each do |name, version, opts| 18 | gem name, version, opts 19 | end 20 | 21 | group :test do 22 | gem 'coveralls' 23 | gem 'rspec' 24 | gem 'webmock' 25 | end 26 | 27 | group :development, :test do 28 | gem 'rubocop' 29 | gem 'rubocop-performance' 30 | gem 'rubocop-rspec' 31 | gem 'simplecov-console' 32 | end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2019 Travis CI GmbH 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /bin/dpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | $LOAD_PATH << File.expand_path('../lib', __dir__) 5 | 6 | $stdout.sync = true 7 | $stderr.sync = true 8 | 9 | require 'dpl' 10 | 11 | Dpl::Cli.new.run(ARGV) 12 | -------------------------------------------------------------------------------- /bin/status: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | $LOAD_PATH << File.expand_path('../lib', __dir__) 5 | 6 | $stdout.sync = true 7 | $stderr.sync = true 8 | 9 | require 'date' 10 | require 'json' 11 | require 'dpl' 12 | 13 | SKIP = %i[help heroku pages].freeze 14 | 15 | class Provider < Struct.new(:path) 16 | def data 17 | { name:, status:, date: format_date(date) } 18 | end 19 | 20 | def name 21 | path.sub('lib/dpl/providers/', '').sub('.rb', '').sub('/', ':') 22 | end 23 | 24 | def status 25 | `grep -n 'status :' #{path}`.chomp.split(':').last 26 | end 27 | 28 | def num 29 | @num ||= `grep -n 'status :' #{path}` =~ /^(\d+)/ && ::Regexp.last_match(1) 30 | end 31 | 32 | def sha 33 | `git blame #{path} -L #{num},#{num}`.split(' ').first 34 | end 35 | 36 | def date 37 | `git log #{sha} --pretty=format:"%ad" -n 1` 38 | end 39 | 40 | def format_date(date) 41 | Date.parse(date).strftime('%F') 42 | end 43 | end 44 | 45 | paths = Dir['lib/dpl/providers/**/*.rb'] 46 | files = paths.map { |path| Provider.new(path) } 47 | files = files.select(&:num) 48 | files = files.sort_by(&:name) 49 | puts JSON.pretty_generate(files.map(&:data)) 50 | -------------------------------------------------------------------------------- /dpl.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $LOAD_PATH << 'lib' 4 | 5 | require 'dpl/version' 6 | 7 | Gem::Specification.new do |s| 8 | s.version = Dpl::VERSION 9 | s.name = 'dpl' 10 | s.authors = ['Konstantin Haase', 'Hiro Asari', 'Sven Fuchs'] 11 | s.email = ['konstantin@travis-ci.com', 'hiro@travis-ci.com', 'sven@travis-ci.com'] 12 | s.homepage = 'https://github.com/travis-ci/dpl' 13 | s.summary = 'Dpl runs deployments at Travis CI' 14 | s.description = 'Dpl (dee-pee-ell) is a tool made for continuous deployment, running deployments at Travis CI.' 15 | s.license = 'MIT' 16 | s.require_path = 'lib' 17 | s.required_ruby_version = '>= 3.1' 18 | 19 | s.executables = ['dpl'] 20 | s.files = Dir['{config/**/*,lib/**/*,[A-Z]*}'].reject { _1.match(/dpl.+\.gem/) } 21 | 22 | s.add_runtime_dependency 'logger', '~> 1.7.0' 23 | s.add_runtime_dependency 'net-http', '~> 0.6.0' 24 | s.add_runtime_dependency 'travis-cl' 25 | s.add_runtime_dependency 'travis-packagecloud-ruby' 26 | s.add_runtime_dependency 'uri', '~> 1.0.2' 27 | s.add_development_dependency 'rake', '~> 13.0' 28 | end 29 | -------------------------------------------------------------------------------- /lib/dpl.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dpl/cli' 4 | require 'dpl/ctx' 5 | require 'dpl/provider' 6 | require 'dpl/version' 7 | require 'dpl/string_ext' 8 | 9 | module Dpl 10 | class Error < StandardError 11 | attr_reader :opts 12 | 13 | def initialize(msg, opts = {}) 14 | super(msg) 15 | @opts = opts 16 | set_backtrace(opts[:backtrace]) if backtrace? 17 | end 18 | 19 | def backtrace? 20 | !!opts[:backtrace] 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/dpl/assets/atlas/install: -------------------------------------------------------------------------------- 1 | if ! command -v atlas-upload &>/dev/null ; then 2 | mkdir -p $HOME/bin $HOME/gopath/src 3 | export PATH="$HOME/bin:$PATH" 4 | 5 | if ! command -v gimme &>/dev/null ; then 6 | curl -sL -o $HOME/bin/gimme https://raw.githubusercontent.com/meatballhat/gimme/master/gimme 7 | chmod +x $HOME/bin/gimme 8 | fi 9 | 10 | if [ -z $GOPATH ]; then 11 | export GOPATH="$HOME/gopath" 12 | else 13 | export GOPATH="$HOME/gopath:$GOPATH" 14 | fi 15 | eval "$(gimme 1.6)" &> /dev/null 16 | 17 | go get github.com/hashicorp/atlas-upload-cli 18 | cp $HOME/gopath/bin/atlas-upload-cli $HOME/bin/atlas-upload 19 | fi 20 | -------------------------------------------------------------------------------- /lib/dpl/assets/convox/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! command -v convox &> /dev/null; then 4 | echo "Downloading convox CLI" 5 | mkdir -p $HOME/bin 6 | export PATH="$HOME/bin:$PATH" 7 | curl -sL -o $HOME/bin/convox %{install_url} 8 | chmod +x $HOME/bin/convox 9 | else 10 | echo "Convox CLI exists. Skipping installation" 11 | fi 12 | -------------------------------------------------------------------------------- /lib/dpl/assets/dpl/git_ssh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec ssh \ 3 | -o CheckHostIP=no \ 4 | -o IdentitiesOnly=yes \ 5 | -o StrictHostKeychecking=no \ 6 | -o UserKnownHostsFile=/dev/null \ 7 | -i %s \ 8 | $@ 9 | -------------------------------------------------------------------------------- /lib/dpl/assets/git/detect_private_key: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for file in $(git ls-files --cached); do 4 | if cat $file | head -n 1 | grep 'BEGIN' | grep 'PRIVATE KEY' > /dev/null; then 5 | echo "Commit rejected: private key detected in $file." 6 | exit 1 7 | fi 8 | done 9 | -------------------------------------------------------------------------------- /lib/dpl/assets/hephy/filter_log: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | $@ 2>&1 | sed -E 's/\[[^ ]+ //' 3 | exit ${PIPESTATUS[0]} 4 | -------------------------------------------------------------------------------- /lib/dpl/assets/pypi/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z ${VIRTUAL_ENV+x} ]; then export PIP_USER=yes; fi && 3 | wget -nv -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && 4 | pip install --upgrade --ignore-installed %{setuptools_arg} %{twine_arg} %{wheel_arg} 5 | -------------------------------------------------------------------------------- /lib/dpl/assets/scalingo/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | curl --remote-name --location https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz && \ 3 | tar -zxvf scalingo_latest_linux_amd64.tar.gz && \ 4 | mv scalingo_*_linux_amd64/scalingo . && \ 5 | rm scalingo_latest_linux_amd64.tar.gz && \ 6 | rm -r scalingo_*_linux_amd64 7 | -------------------------------------------------------------------------------- /lib/dpl/ctx.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dpl/ctx/bash' 4 | require 'dpl/ctx/test' 5 | -------------------------------------------------------------------------------- /lib/dpl/helper/assets.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'fileutils' 4 | 5 | module Dpl 6 | module Assets 7 | class Asset < Struct.new(:provider, :namespace, :name) 8 | include FileUtils 9 | 10 | DIR = File.expand_path('../assets', __dir__) 11 | 12 | def copy(target) 13 | cp path, File.expand_path(target) 14 | end 15 | 16 | def read 17 | exists? ? provider.interpolate(File.read(path)) : unknown 18 | end 19 | 20 | def exists? 21 | File.exist?(path) 22 | end 23 | 24 | def unknown 25 | raise "Could not find asset #{path}" 26 | end 27 | 28 | def path 29 | "#{DIR}/#{namespace}/#{name}" 30 | end 31 | end 32 | 33 | def asset(*args) 34 | name, namespace = args.reverse 35 | Asset.new(self, namespace || registry_key, name) 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/dpl/helper/config_file.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module ConfigFile 5 | def self.included(base) 6 | base.extend(ClassMethods) 7 | end 8 | 9 | # should this sit in Cl? 10 | module ClassMethods 11 | attr_reader :config_files 12 | 13 | def config(*paths) 14 | if paths.any? 15 | @config_files = paths 16 | elsif config_files 17 | paths = config_files.dup 18 | opts = paths.last.is_a?(Hash) ? paths.pop : {} 19 | conf = ConfigFiles.new(paths, opts).config 20 | known = self.opts.map(&:name).map(&:to_sym) 21 | conf.select { |key, _| known.include?(key) } 22 | else 23 | {} 24 | end 25 | end 26 | end 27 | 28 | class ConfigFiles < Struct.new(:paths, :opts) 29 | def config 30 | paths.map { |path| parse(path) }.inject(&:merge) || {} 31 | end 32 | 33 | def parse(path) 34 | str = File.exist?(path) ? File.read(path) : '' 35 | opts = str.lines.select { |line| line.include?('=') }.map(&:strip) 36 | opts = opts.map { |pair| pair.split('=', 2) }.to_h 37 | opts.transform_keys { |key| strip_prefix(key).to_sym } 38 | end 39 | 40 | def strip_prefix(str) 41 | opts[:prefix] ? str.sub(/^#{opts[:prefix]}[-_]?/, '') : str 42 | end 43 | end 44 | 45 | def opts 46 | @opts ||= self.class.config.merge(super) 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /lib/dpl/helper/github.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dpl/helper/transliterate' 4 | 5 | # I18n.load_path << File.expand_path('config/transliterate.yml') 6 | # I18n.eager_load! 7 | # I18n.config.available_locales_set << :en # seems really wrong, but ¯\_(ツ)_/¯ 8 | 9 | module Dpl 10 | module Github 11 | include Transliterate 12 | 13 | def normalize_filename(str) 14 | str = File.basename(str) 15 | str = str.split(' ').first 16 | str = transliterate(str) 17 | str.gsub(/[^\w@+\-_]/, '.') 18 | end 19 | 20 | extend self 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/dpl/helper/memoize.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Memoize 4 | class ArgsError < StandardError; end 5 | 6 | module ClassMethods 7 | def memoize(name) 8 | ivar = :"@#{name.to_s.sub('?', '_predicate')}" 9 | prepend Module.new { 10 | define_method(name) do |*args| 11 | raise ArgsError, 'cannot pass arguments to memoized method %p' % name unless args.empty? 12 | return instance_variable_get(ivar) if instance_variable_defined?(ivar) 13 | 14 | instance_variable_set(ivar, super()) 15 | end 16 | } 17 | end 18 | end 19 | 20 | def self.included(base) 21 | base.extend(ClassMethods) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/dpl/helper/squiggle.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Beloved squiggly heredocs did not exist in Ruby 2.1, which we still want to 4 | # support, so let's give kudos with a method `sq`. 5 | module Squiggle 6 | # Outdents each line on a multiline string by the number of leading 7 | # whitespace characters on the first line. 8 | # 9 | # This method exists so we can unindet heredoc strings the same way that 10 | # Ruby 2.2's squiggly heredocs work, but still support Ruby 2.1 for the 11 | # time being. 12 | # 13 | # For example: 14 | # 15 | # str = sq(<<-str) 16 | # This multiline string will be outdented by two characters, 17 | # so the extra indentation on this line will be kept, 18 | # while this line sits on the same level as the first line. 19 | # str 20 | def sq(str) 21 | width = str =~ /( *)\S/ && ::Regexp.last_match(1).size 22 | str.lines.map { |line| line.gsub(/^ {#{width}}/, '') }.join 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/dpl/helper/transliterate.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Transliterate 5 | APPROXIMATIONS = YAML.load(File.read(File.expand_path('../../../config/transliterate.yml', __dir__))) 6 | 7 | def transliterate(string, replacement = '.') 8 | string.gsub(/[^\x00-\x7f]/u) do |char| 9 | APPROXIMATIONS[char] || replacement 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/dpl/helper/wrap.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Wrap 4 | module_function 5 | 6 | def wrap(str, width = 80) 7 | str.lines.map do |line| 8 | line.size > width ? line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip : line 9 | end.join("\n") 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/dpl/helper/zip.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'tempfile' 4 | 5 | module Dpl 6 | class Zip < Struct.new(:src, :dest, :opts) 7 | ZIP_EXT = %w[.zip .jar].freeze 8 | 9 | def initialize(*) 10 | require 'zip' 11 | super 12 | end 13 | 14 | def zip 15 | if zip_file? 16 | File.new(src) 17 | elsif dir? 18 | zip_dir 19 | else 20 | zip_file 21 | end 22 | end 23 | 24 | def zip_dir 25 | create(Dir.glob(*glob).reject { |path| dir?(path) }) 26 | end 27 | 28 | def zip_file 29 | create([src]) 30 | end 31 | 32 | def create(files) 33 | ::Zip::File.open(dest, ::Zip::File::CREATE) do |zip| 34 | files.each do |file| 35 | zip.add(file.sub("#{src}/", ''), file) 36 | end 37 | end 38 | File.new(dest) 39 | end 40 | 41 | def zip_file? 42 | exts.include?(File.extname(src)) 43 | end 44 | 45 | def dir?(path = src) 46 | File.directory?(path) 47 | end 48 | 49 | def copy 50 | FileUtils.cp(src, dest) 51 | end 52 | 53 | def glob 54 | glob = ["#{src}/**/*"] 55 | glob << File::FNM_DOTMATCH if dot_match? 56 | glob 57 | end 58 | 59 | def dot_match? 60 | opts[:dot_match] 61 | end 62 | 63 | def exts 64 | opts[:exts] ||= ZIP_EXT 65 | end 66 | 67 | def opts 68 | super || {} 69 | end 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /lib/dpl/provider/status.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | class Provider < Cl::Cmd 5 | class Status < Struct.new(:provider, :status, :info) 6 | STATUS = %i[dev alpha beta stable deprecated].freeze 7 | 8 | MSG = { 9 | dev: 'Support for deployments to %s is in **development**', 10 | alpha: 'Support for deployments to %s is in **alpha**', 11 | beta: 'Support for deployments to %s is in **beta**', 12 | deprecated: 'Support for deployments to %s is *deprecated**', 13 | pre_stable: 'Please see [Maturity Levels](%s) for details.' 14 | }.freeze 15 | 16 | URL = 'https://github.com/travis-ci/dpl/#maturity-levels' 17 | 18 | def initialize(provider, status, info) 19 | unknown!(status) unless known?(status) 20 | super 21 | end 22 | 23 | def announce? 24 | !stable? 25 | end 26 | 27 | def msg 28 | msg = (MSG[status] % name).to_s 29 | msg << "(#{info})" if info 30 | msg << ". #{MSG[:pre_stable] % URL}" if pre_stable? 31 | msg 32 | end 33 | 34 | private 35 | 36 | def name 37 | provider.full_name 38 | end 39 | 40 | def pre_stable? 41 | STATUS.index(status) < STATUS.index(:stable) 42 | end 43 | 44 | def stable? 45 | status == :stable 46 | end 47 | 48 | def deprecated? 49 | status == :deprecated 50 | end 51 | 52 | def known?(status) 53 | STATUS.include?(status) 54 | end 55 | 56 | def unknown!(status) 57 | raise "Unknown status: #{status.inspect}. Known statuses are: #{STATUS.map(&:inspect).join(', ')}" 58 | end 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/dpl/providers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dpl/providers/anynines' 4 | require 'dpl/providers/azure_web_apps' 5 | require 'dpl/providers/bintray' 6 | require 'dpl/providers/boxfuse' 7 | require 'dpl/providers/bluemixcloudfoundry' 8 | require 'dpl/providers/cargo' 9 | require 'dpl/providers/datica' 10 | require 'dpl/providers/chef_supermarket' 11 | require 'dpl/providers/cloud66' 12 | require 'dpl/providers/cloudfiles' 13 | require 'dpl/providers/cloudformation' 14 | require 'dpl/providers/cloudfoundry' 15 | require 'dpl/providers/codedeploy' 16 | require 'dpl/providers/ecr' 17 | require 'dpl/providers/convox' 18 | require 'dpl/providers/elasticbeanstalk' 19 | require 'dpl/providers/engineyard' 20 | require 'dpl/providers/firebase' 21 | require 'dpl/providers/flynn' 22 | require 'dpl/providers/gae' 23 | require 'dpl/providers/gcs' 24 | require 'dpl/providers/git_push' 25 | require 'dpl/providers/gleis' 26 | require 'dpl/providers/hackage' 27 | require 'dpl/providers/hephy' 28 | require 'dpl/providers/heroku' 29 | require 'dpl/providers/lambda' 30 | require 'dpl/providers/launchpad' 31 | require 'dpl/providers/netlify' 32 | require 'dpl/providers/npm' 33 | require 'dpl/providers/nuget' 34 | require 'dpl/providers/openshift' 35 | require 'dpl/providers/opsworks' 36 | # require 'dpl/providers/packagecloud' 37 | require 'dpl/providers/pages' 38 | require 'dpl/providers/puppetforge' 39 | require 'dpl/providers/pypi' 40 | require 'dpl/providers/releases' 41 | require 'dpl/providers/rubygems' 42 | require 'dpl/providers/s3' 43 | require 'dpl/providers/scalingo' 44 | require 'dpl/providers/script' 45 | require 'dpl/providers/snap' 46 | require 'dpl/providers/surge' 47 | require 'dpl/providers/testfairy' 48 | require 'dpl/providers/transifex' 49 | -------------------------------------------------------------------------------- /lib/dpl/providers/azure_web_apps.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class AzureWebApps < Provider 6 | register :azure_web_apps 7 | 8 | status :alpha 9 | 10 | full_name 'Azure Web Apps' 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | env :AZURE_WA 17 | 18 | opt '--username NAME', 'Web App Deployment Username', required: true 19 | opt '--password PASS', 'Web App Deployment Password', required: true, secret: true 20 | opt '--site SITE', 'Web App name (e.g. myapp in myapp.azurewebsites.net)', required: true 21 | opt '--slot SLOT', 'Slot name (if your app uses staging deployment)' 22 | opt '--verbose', 'Print deployment output from Azure. Warning: If authentication fails, Git prints credentials in clear text. Correct credentials remain hidden.' 23 | 24 | needs :git 25 | 26 | cmds checkout: 'git checkout HEAD', 27 | add: 'git add . --all --force', 28 | commit: 'git commit -m "Cleanup commit"', 29 | deploy: 'git push --force --quiet %{url} HEAD:refs/heads/master' 30 | 31 | msgs commit: 'Committing changes to git', 32 | deploy: 'Deploying to Azure Web App: %{site}' 33 | 34 | errs push: 'Failed pushing to Azure Web Apps' 35 | 36 | URL = 'https://%s:%s@%s.scm.azurewebsites.net:443/%s.git' 37 | 38 | def setup 39 | commit if git_dirty? && !cleanup? 40 | end 41 | 42 | def deploy 43 | shell :deploy, silence: !verbose? 44 | end 45 | 46 | private 47 | 48 | def url 49 | format(URL, username, password, target, site) 50 | end 51 | 52 | def target 53 | slot || site 54 | end 55 | 56 | def commit 57 | shell :checkout 58 | shell :add 59 | shell :commit 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/dpl/providers/boxfuse.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Boxfuse < Provider 6 | register :boxfuse 7 | 8 | status :alpha 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :boxfuse 15 | 16 | opt '--user USER', required: true 17 | opt '--secret SECRET', required: true, secret: true 18 | opt '--payload PAYLOAD' 19 | opt '--app APP' 20 | opt '--version VERSION' 21 | opt '--env ENV' 22 | opt '--config_file FILE', alias: :configfile, deprecated: :configfile 23 | opt '--extra_args ARGS' 24 | 25 | URL = 'https://files.boxfuse.com/com/boxfuse/client/boxfuse-commandline/1.33.0.1460/boxfuse-commandline-1.33.0.1460-linux-x64.tar.gz' 26 | 27 | cmds install: 'curl -L %{URL} | tar xz', 28 | deploy: 'boxfuse/boxfuse run %{deploy_opts}' 29 | 30 | def validate 31 | # TODO: check if the config file exists (it seems `boxfuse` doesn't) 32 | end 33 | 34 | def install 35 | shell :install 36 | end 37 | 38 | def deploy 39 | shell :deploy 40 | end 41 | 42 | private 43 | 44 | def deploy_opts 45 | opts = [*opts_for(%i[user secret payload app env version], prefix: '-')] 46 | opts << "-configfile=#{config_file}" if config_file? 47 | opts << extra_args if extra_args? 48 | opts.join(' ') 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lib/dpl/providers/cargo.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Cargo < Provider 6 | register :cargo 7 | 8 | status :stable 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :cargo 15 | 16 | opt '--token TOKEN', 'Cargo registry API token', required: true, secret: true 17 | opt '--allow_dirty', 'Allow publishing from a dirty git working directory' 18 | 19 | cmds publish: 'cargo publish %{publish_opts}' 20 | 21 | def deploy 22 | shell :publish 23 | end 24 | 25 | private 26 | 27 | def publish_opts 28 | opts_for(%i[token allow_dirty], dashed: true) 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/dpl/providers/cloud66.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Cloud66 < Provider 6 | register :cloud66 7 | 8 | status :alpha 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :cloud66 15 | 16 | opt '--redeployment_hook URL', 'The redeployment hook URL', required: true, secret: true 17 | 18 | msgs failed: 'Redeployment failed (%s)' 19 | 20 | def deploy 21 | response = client.request(request) 22 | error :failed, response.code if response.code != '200' 23 | end 24 | 25 | private 26 | 27 | def client 28 | Net::HTTP.new(uri.host, uri.port).tap do |client| 29 | client.use_ssl = use_ssl? 30 | end 31 | end 32 | 33 | def request 34 | Net::HTTP::Post.new(uri.path) 35 | end 36 | 37 | def uri 38 | @uri ||= URI.parse(redeployment_hook) 39 | end 40 | 41 | def use_ssl? 42 | uri.scheme.downcase == 'https' 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/dpl/providers/cloudfiles.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Cloudfiles < Provider 6 | register :cloudfiles 7 | 8 | status :alpha 9 | 10 | full_name 'Cloud Files' 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | gem 'nokogiri', '~> 1.15' 17 | gem 'fog-core', '~> 2.3', require: 'fog/core' 18 | gem 'fog-rackspace', '~> 0.1.6', git: 'https://github.com/travis-oss/fog-rackspace', require: 'fog/rackspace' 19 | 20 | env :cloudfiles 21 | 22 | opt '--username USER', 'Rackspace username', required: true 23 | opt '--api_key KEY', 'Rackspace API key', required: true, secret: true 24 | opt '--region REGION', 'Cloudfiles region', required: true, enum: %w[ord dfw syd iad hkg] 25 | opt '--container NAME', 'Name of the container that files will be uploaded to', required: true 26 | opt '--glob GLOB', 'Paths to upload', default: '**/*' 27 | opt '--dot_match', 'Upload hidden files starting a dot' 28 | 29 | msgs missing_container: 'The specified container does not exist.' 30 | 31 | def deploy 32 | paths.each do |path| 33 | container.files.create(key: path, body: File.open(path)) 34 | end 35 | end 36 | 37 | def paths 38 | paths = Dir.glob(*glob) 39 | paths.reject { |path| File.directory?(path) } 40 | end 41 | 42 | def glob 43 | glob = [super] 44 | glob << File::FNM_DOTMATCH if dot_match? 45 | glob 46 | end 47 | 48 | def container 49 | @container ||= api.directories.get(super) || error(:missing_container) 50 | end 51 | 52 | def api 53 | @api ||= Fog::Storage.new( 54 | provider: 'Rackspace', 55 | rackspace_username: username, 56 | rackspace_api_key: api_key, 57 | rackspace_region: region 58 | ) 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/dpl/providers/datica.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Datica < Provider 6 | register :datica 7 | 8 | status :dev 9 | 10 | register :datica, :catalyze 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | env :datica, :catalyze 17 | 18 | opt '--target TARGET', 'The git remote repository to deploy to', required: true 19 | opt '--path PATH', 'Path to files to deploy', default: '.' 20 | 21 | needs :git 22 | 23 | cmds checkout: 'git checkout HEAD', 24 | add: 'git add %{path} --all --force', 25 | commit: 'git commit -m "%{message}" --quiet', 26 | push: 'git push --force %{target} HEAD:master' 27 | 28 | msgs commit: 'Committing build files for deployment', 29 | push: 'Deploying to Datica: %{target}' 30 | 31 | def setup 32 | commit if git_dirty? && !cleanup? 33 | end 34 | 35 | def deploy 36 | shell :push 37 | end 38 | 39 | private 40 | 41 | def commit 42 | info :commit 43 | shell :checkout 44 | shell :add 45 | shell :commit 46 | end 47 | 48 | def message 49 | vars.empty? ? 'Local build' : 'Build #%s (%s) of %s@%s' % vars 50 | end 51 | 52 | VARS = %w[ 53 | TRAVIS_BUILD_NUMBER 54 | TRAVIS_COMMIT 55 | TRAVIS_REPO_SLUG 56 | TRAVIS_BRANCH 57 | ].freeze 58 | 59 | def vars 60 | @vars ||= ENV.values_at(*VARS).compact 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/dpl/providers/firebase.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Firebase < Provider 6 | register :firebase 7 | 8 | status :stable 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | node_js '>= 8.0.0' 15 | 16 | npm 'firebase-tools@^6.3', 'firebase' 17 | 18 | path 'node_modules/.bin' 19 | 20 | env :firebase 21 | 22 | opt '--token TOKEN', 'Firebase CI access token (generate with firebase login:ci)', required: true, secret: true 23 | opt '--project NAME', 'Firebase project to deploy to (defaults to the one specified in your firebase.json)' 24 | opt '--message MSG', 'Message describing this deployment.' 25 | opt '--only SERVICES', 'Firebase services to deploy', note: 'can be a comma-separated list' 26 | opt '--force', 'Whether or not to delete Cloud Functions missing from the current working directory' 27 | 28 | cmds deploy: 'firebase deploy --non-interactive %{deploy_opts}' 29 | errs deploy: 'Firebase deployment failed' 30 | msgs missing_config: 'Missing firebase.json' 31 | 32 | def validate 33 | error :missing_config unless File.exist?('firebase.json') 34 | end 35 | 36 | def deploy 37 | shell :deploy 38 | end 39 | 40 | def deploy_opts 41 | opts_for(%i[project message token only force]) 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/dpl/providers/flynn.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Flynn < Provider 6 | register :flynn 7 | 8 | status :dev 9 | 10 | full_name 'Flynn' 11 | 12 | description sq(<<-STR) 13 | Flynn provider for Dpl 14 | STR 15 | 16 | opt '--git URL', 'Flynn Git remote URL', required: true 17 | 18 | needs :git, :git_http_user_agent 19 | 20 | cmds fetch: 'git fetch origin $TRAVIS_BRANCH --unshallow', 21 | push: 'git push %{remote} HEAD:refs/heads/master -f' 22 | 23 | def deploy 24 | shell :fetch, assert: false 25 | shell :push 26 | end 27 | 28 | private 29 | 30 | def remote 31 | git 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/dpl/providers/gleis.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Gleis < Provider 6 | register :gleis 7 | 8 | status :alpha 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | gem 'gleis', '~> 0.8.0' 15 | 16 | env :gleis 17 | 18 | opt '--app APP', 'Gleis application to upload to', default: :repo_name 19 | opt '--username NAME', 'Gleis username', required: true 20 | opt '--password PASS', 'Gleis password', required: true, secret: true 21 | opt '--key_name NAME', 'Name of the SSH deploy key pushed to Gleis', default: 'dpl_deploy_key' 22 | opt '--verbose' 23 | 24 | needs :ssh_key 25 | 26 | cmds login: 'gleis auth login %{username} %{password} --skip-keygen', 27 | logout: 'gleis auth logout', 28 | validate: 'gleis app status -a %{app}', 29 | add_key: 'gleis auth key add %{file} %{key_name}', 30 | remove_key: 'gleis auth key remove %{key_name}', 31 | git_url: 'gleis app git -a %{app} -q', 32 | deploy: 'git push %{push_opts} -f %{git_url} HEAD:refs/heads/master' 33 | 34 | errs login: 'Login failed', 35 | validate: 'Application not found', 36 | add_key: 'Adding SSH key failed', 37 | remove_key: 'Removing key failed', 38 | git_url: 'Failed to retrieve Git URL', 39 | deploy: 'Deploying application failed' 40 | 41 | attr_reader :git_url 42 | 43 | def login 44 | shell :login 45 | end 46 | 47 | def setup 48 | @git_url = shell :git_url, capture: true 49 | end 50 | 51 | def validate 52 | shell :validate 53 | end 54 | 55 | def add_key(file) 56 | shell :add_key, file: 57 | end 58 | 59 | def deploy 60 | shell :deploy 61 | end 62 | 63 | def remove_key 64 | shell :remove_key 65 | end 66 | 67 | private 68 | 69 | def push_opts 70 | '-v' if verbose? 71 | end 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /lib/dpl/providers/hackage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Hackage < Provider 6 | register :hackage 7 | 8 | status :alpha 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :hackage 15 | 16 | opt '--username USER', 'Hackage username', required: true 17 | opt '--password USER', 'Hackage password', required: true, secret: true 18 | opt '--publish', 'Whether or not to publish the package' 19 | 20 | cmds check: 'cabal check', 21 | sdist: 'cabal sdist', 22 | upload: 'cabal upload %{upload_opts} %{path}' 23 | 24 | errs check: 'cabal check failed', 25 | sdist: 'cabal sdist failed', 26 | upload: 'cabal upload failed' 27 | 28 | def validate 29 | shell :check 30 | end 31 | 32 | def prepare 33 | shell :sdist 34 | end 35 | 36 | def deploy 37 | tar_files.each do |path| 38 | shell :upload, path: 39 | end 40 | end 41 | 42 | private 43 | 44 | def upload_opts 45 | opts_for(%i[publish username password]) 46 | end 47 | 48 | def tar_files 49 | Dir.glob('dist/*.tar.gz').sort 50 | end 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/dpl/providers/heroku/git.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Heroku 6 | class Git < Heroku 7 | register :'heroku:git' 8 | 9 | status :alpha 10 | 11 | full_name 'Heroku Git' 12 | 13 | description sq(<<-STR) 14 | tbd 15 | STR 16 | 17 | required :api_key, %i[username password] 18 | 19 | opt '--api_key KEY', 'Heroku API key', secret: true 20 | opt '--username USER', 'Heroku username', alias: :user 21 | opt '--password PASS', 'Heroku password', secret: true 22 | opt '--git URL', 'Heroku Git remote URL' 23 | 24 | needs :git, :git_http_user_agent 25 | 26 | cmds fetch: 'git fetch origin $TRAVIS_BRANCH --unshallow', 27 | push: 'git push %{remote} HEAD:refs/heads/master -f' 28 | 29 | def prepare 30 | write_netrc if write_netrc? 31 | end 32 | 33 | def deploy 34 | shell :fetch, assert: false 35 | shell :push 36 | end 37 | 38 | private 39 | 40 | def remote 41 | git || "https://git.heroku.com/#{app}.git" 42 | end 43 | 44 | def write_netrc? 45 | remote.start_with?('https://') 46 | end 47 | 48 | def write_netrc 49 | super('git.heroku.com', email, api_key || password) 50 | end 51 | end 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/dpl/providers/netlify.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Netlify < Provider 6 | register :netlify 7 | 8 | status :stable 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | node_js '>= 18.14.0' 15 | 16 | npm 'netlify-cli', 'netlify' 17 | 18 | env :netlify 19 | 20 | opt '--site ID', 'A site ID to deploy to', required: true 21 | opt '--auth TOKEN', 'An auth token to log in with', required: true, secret: true 22 | opt '--dir DIR', 'Specify a folder to deploy' 23 | opt '--functions FUNCS', 'Specify a functions folder to deploy' 24 | opt '--message MSG', 'A message to include in the deploy log' 25 | opt '--prod', 'Deploy to production' 26 | 27 | def deploy 28 | shell "netlify deploy #{deploy_opts}" 29 | end 30 | 31 | private 32 | 33 | def deploy_opts 34 | opts_for(%i[site auth dir functions message prod]) 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/dpl/providers/nuget.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Nuget < Provider 6 | status :alpha 7 | 8 | full_name 'nuget' 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :nuget, :dotnet 15 | 16 | opt '--api_key KEY', 'NuGet registry API key', required: true, secret: true, note: 'can be retrieved from your NuGet registry provider', see: 'https://docs.npmjs.com/creating-and-viewing-authentication-tokens' 17 | opt '--registry URL', 'NuGet registry url', required: true, eg: 'https://www.myget.org/F/org-name/api/v2/package' 18 | opt '--src SRC', 'The nupkg file(s) to publish', default: '*.nupkg' 19 | opt '--no_symbols', 'Do not push symbols, even if present' 20 | opt '--skip_duplicate', 'Do not overwrite existing packages' 21 | 22 | msgs login: 'Authenticating with API key %{api_key}', 23 | push: 'Pushing package %{src} to %{registry}' 24 | 25 | cmds push: 'dotnet nuget push %{src} -k %{api_key} -s %{registry} %{push_opts}' 26 | 27 | errs push: 'Failed to push' 28 | 29 | def deploy 30 | info :login 31 | shell :push 32 | end 33 | 34 | private 35 | 36 | def push_opts 37 | opts_for(%i[no_symbols skip_duplicate], dashed: true) 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/dpl/providers/openshift.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Openshift < Provider 6 | register :openshift 7 | 8 | status :stable 9 | 10 | full_name 'OpenShift' 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | env :openshift 17 | 18 | opt '--server SERVER', 'OpenShift server', required: true 19 | opt '--token TOKEN', 'OpenShift token', required: true, secret: true 20 | opt '--project PROJECT', 'OpenShift project', required: true 21 | opt '--app APP', 'OpenShift application', default: :repo_name 22 | 23 | cmds install: 'curl %{URL} | tar xz', 24 | login: './oc login --token=%{token} --server=%{server}', 25 | prepare: './oc project %{project}', 26 | deploy: './oc start-build %{app} --follow --commit %{git_sha}' 27 | 28 | errs install: 'CLI tool installation failed', 29 | login: 'Authentication failed', 30 | prepare: 'Unable to select project %{project}', 31 | deploy: 'Deployment failed' 32 | 33 | URL = 'https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1/linux/oc.tar.gz' 34 | 35 | def install 36 | shell :install 37 | end 38 | 39 | def login 40 | shell :login 41 | end 42 | 43 | def prepare 44 | shell :prepare 45 | end 46 | 47 | def deploy 48 | shell :deploy 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lib/dpl/providers/pages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Pages < Provider 6 | register :pages 7 | 8 | abstract 9 | 10 | env :github, :pages 11 | 12 | opt '--strategy NAME', 'GitHub Pages deployment strategy', default: 'git', enum: %w[api git] 13 | end 14 | end 15 | end 16 | 17 | require 'dpl/providers/pages/git' 18 | require 'dpl/providers/pages/api' 19 | -------------------------------------------------------------------------------- /lib/dpl/providers/puppetforge.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Puppetforge < Provider 6 | register :puppetforge 7 | 8 | status :alpha 9 | 10 | full_name 'Puppet Forge' 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | gem 'racc', '~> 1.7' 17 | gem 'puppet', '~> 7.25', require: 'puppet/face' 18 | gem 'puppet-blacksmith', '~> 7', require: 'puppet_blacksmith' 19 | 20 | env :puppetforge 21 | 22 | opt '--username NAME', 'Puppet Forge user name', required: true, alias: :user 23 | opt '--password PASS', 'Puppet Forge password', required: true, secret: true 24 | opt '--url URL', 'Puppet Forge URL to deploy to', default: 'https://forgeapi.puppetlabs.com/' 25 | 26 | msgs upload: 'Uploading to Puppet Forge %s/%s' 27 | 28 | def validate 29 | file.metadata 30 | end 31 | 32 | def deploy 33 | build 34 | info :upload, forge.username, file.name 35 | forge.push!(file.name) 36 | end 37 | 38 | def file 39 | @file ||= Blacksmith::Modulefile.new 40 | end 41 | 42 | def build 43 | Puppet::Face['module', :current].build('./') 44 | end 45 | 46 | def forge 47 | @forge ||= Blacksmith::Forge.new(username, password, url) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/dpl/providers/script.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Script < Provider 6 | register :script 7 | 8 | status :stable 9 | 10 | summary 'Minimal provider that executes a custom command' 11 | 12 | description sq(<<-STR) 13 | This deployment provider executes a single, custom command. This is 14 | usually a script that is contained in your repository, but it can be 15 | any command executable in the build environment. 16 | 17 | It is possible to pass arguments to a script deployment like so: 18 | 19 | dpl script -s './scripts/deploy.sh production --verbose' 20 | 21 | Deployment will be marked a failure if the script exits with nonzero 22 | status. 23 | STR 24 | 25 | opt '-s', '--script SCRIPT', 'The script to execute', required: true 26 | 27 | def deploy 28 | shell script, assert: 'Script failed with status %{status}' 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/dpl/providers/snap.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Snap < Provider 6 | register :snap 7 | 8 | status :stable 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | env :snap 15 | 16 | opt '--token TOKEN', 'Snap API token', required: true, secret: true 17 | opt '--snap STR', 'Path to the snap to be pushed (can be a glob)', default: '**/*.snap' 18 | opt '--channel CHAN', 'Channel into which the snap will be released', default: 'edge' 19 | 20 | apt 'snapd', 'snap' 21 | 22 | cmds apt_get_update: 'sudo apt-get update -qq', 23 | update_snapd: 'sudo apt-get install snapd', 24 | install: 'sudo snap install snapcraft --classic', 25 | login: 'echo "%{token}" | snapcraft login --with -', 26 | deploy: 'snapcraft push %{snap_path} --release=%{channel}' 27 | 28 | msgs login: 'Attemping to login ...', 29 | no_snaps: 'No snap found matching %{snap}', 30 | multiple_snaps: 'Multiple snaps found matching %{snap}: %{snap_paths}', 31 | deploy: 'Pushing snap %{snap_path}' 32 | 33 | def install 34 | return if which 'snapcraft' 35 | 36 | shell :apt_get_update 37 | shell :update_snapd 38 | shell :install 39 | ENV['PATH'] += ':/snap/bin' 40 | end 41 | 42 | def login 43 | shell :login, assert: 'Failed to authenticate: %{err}', success: '%{out}', capture: true 44 | end 45 | 46 | def validate 47 | error :no_snaps if snaps.empty? 48 | error :multiple_snaps if snaps.size > 1 49 | end 50 | 51 | def deploy 52 | shell :deploy 53 | end 54 | 55 | def snap_path 56 | snaps.first 57 | end 58 | 59 | def snap_paths 60 | snaps.join(', ') 61 | end 62 | 63 | def snaps 64 | @snaps ||= Dir[snap].sort 65 | end 66 | end 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /lib/dpl/providers/surge.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'open-uri' 4 | 5 | module Dpl 6 | module Providers 7 | class Surge < Provider 8 | register :surge 9 | 10 | status :stable 11 | 12 | description sq(<<-STR) 13 | tbd 14 | STR 15 | 16 | node_js '>= 8.8.1' 17 | 18 | gem 'json' 19 | npm :surge 20 | env :surge 21 | 22 | opt '--login EMAIL', 'Surge login (the email address you use with Surge)', required: true 23 | opt '--token TOKEN', 'Surge login token (can be retrieved with `surge token`)', required: true, secret: true 24 | opt '--domain NAME', 'Domain to publish to. Not required if the domain is set in the CNAME file in the project folder.' 25 | opt '--project PATH', 'Path to project directory relative to repo root', default: '.' 26 | 27 | cmds deploy: 'surge %{project} %{domain}' 28 | 29 | msgs invalid_project: '%{project} is not a directory', 30 | missing_domain: 'Please set the domain in .travis.yml or in a CNAME file in the project directory' 31 | 32 | def login 33 | ENV['SURGE_LOGIN'] ||= opts[:login] 34 | ENV['SURGE_TOKEN'] ||= opts[:token] 35 | end 36 | 37 | def validate 38 | error :invalid_project if invalid_project? 39 | error :missing_domain if missing_domain? 40 | end 41 | 42 | def deploy 43 | shell :deploy 44 | end 45 | 46 | def invalid_project? 47 | !File.directory?(project) 48 | end 49 | 50 | def missing_domain? 51 | !domain && !File.exist?("#{project}/CNAME") 52 | end 53 | 54 | def project 55 | expand(super, build_dir) 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/dpl/providers/transifex.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | module Providers 5 | class Transifex < Provider 6 | register :transifex 7 | 8 | status :alpha 9 | 10 | description sq(<<-STR) 11 | tbd 12 | STR 13 | 14 | python '>= 2.7', '!= 3.0', '!= 3.1', '!= 3.2', '!= 3.3', '< 3.12' 15 | 16 | required :api_token, %i[username password] 17 | 18 | env :transifex 19 | 20 | opt '--api_token TOKEN', 'Transifex API token', secret: true 21 | opt '--username NAME', 'Transifex username' 22 | opt '--password PASS', 'Transifex password', secret: true 23 | opt '--hostname NAME', 'Transifex hostname', default: 'www.transifex.com' 24 | opt '--cli_version VER', 'CLI version to install', default: '>=0.11' 25 | 26 | cmds status: 'tx status', 27 | push: 'tx push --source --no-interactive' 28 | 29 | msgs login: 'Writing ~/.transifexrc (user: %{username}, password: %{password})' 30 | errs push: 'Failure pushing to Transifex' 31 | 32 | RC = sq(<<-RC) 33 | [%{url}] 34 | hostname = %{url} 35 | username = %{username} 36 | password = %{password} 37 | RC 38 | 39 | def install 40 | pip_install 'transifex-client', 'tx', cli_version 41 | end 42 | 43 | def login 44 | info :login 45 | write_rc 46 | shell :status 47 | end 48 | 49 | def deploy 50 | shell :push, retry: true 51 | end 52 | 53 | private 54 | 55 | def write_rc 56 | write_file '~/.transifexrc', interpolate(RC, opts, secure: true) 57 | end 58 | 59 | def username 60 | super || 'api' 61 | end 62 | 63 | def password 64 | super || api_token 65 | end 66 | 67 | def url 68 | hostname.start_with?('https://') ? hostname : "https://#{hostname}" 69 | end 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /lib/dpl/string_ext.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class String 4 | def whitelist 5 | @is_whitelisted = true 6 | 7 | self 8 | end 9 | 10 | def whitelisted? 11 | @is_whitelisted 12 | end 13 | 14 | def blacklist 15 | @is_whitelisted = false 16 | 17 | self 18 | end 19 | 20 | def blacklisted? 21 | @is_whitelisted.nil? ? false : !@is_whitelisted 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/dpl/support/aws_sdk_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Silences "Struct::Tms is deprecated" warnings on Ruby 2.6.2 that would 4 | # otherwise spam hundereds of warnings, on apparently every single const 5 | # eager loaded (or something). The constant Tms is not used anywhere in 6 | # the aws-sdk gem, so it seems safe to skip it. 7 | # 8 | # Maybe submit a patch to aws-sdk? 9 | 10 | Aws::EagerLoader.class_eval do 11 | def load(klass_or_module) 12 | @loaded << klass_or_module 13 | klass_or_module.constants.each do |const_name| 14 | next if const_name == :Tms 15 | 16 | path = klass_or_module.autoload?(const_name) 17 | begin 18 | require(path) if path 19 | const = klass_or_module.const_get(const_name) 20 | self.load(const) if const.is_a?(Module) && !@loaded.include?(const) 21 | rescue LoadError 22 | end 23 | end 24 | self 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/dpl/support/gems.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'ripper' 4 | 5 | module Dpl 6 | module Support 7 | class Gems < Struct.new(:glob, :opts) 8 | def each(&block) 9 | all.uniq.each(&block) 10 | end 11 | 12 | def all 13 | Dir[glob].sort.inject([]) do |gems, path| 14 | next gems if except.any? { |str| path.include?(str) } 15 | 16 | gems + Parse.new(File.read(path)).gems 17 | end 18 | end 19 | 20 | def except 21 | @except ||= Array(opts[:except]).map(&:to_s) 22 | end 23 | 24 | def opts 25 | super || {} 26 | end 27 | 28 | class Parse < Struct.new(:code) 29 | def gems 30 | return [] unless sexp 31 | walk(*sexp).flatten.each_slice(3).to_a 32 | end 33 | 34 | def walk(key, *nodes) 35 | case key 36 | when :program 37 | nodes[0].map { |node| walk(*node) }.compact 38 | when :module 39 | walk(*nodes[1]) 40 | when :class 41 | walk(*nodes[2]) 42 | when :bodystmt 43 | nodes[0].map { |node| walk(*node) }.compact 44 | when :command 45 | walk(*nodes[1]) if nodes[0][1] == 'gem' 46 | when :args_add_block 47 | args = nodes[0].map { |node| walk(*node) } 48 | opts = args.last.is_a?(Hash) ? args.pop : {} 49 | name, version = *args 50 | [name, version, opts] 51 | when :bare_assoc_hash 52 | walk(*nodes[0][0]) 53 | when :assoc_new 54 | [nodes.map { |node| walk(*node) }].to_h 55 | when :@label 56 | nodes.first.sub(':', '').to_sym 57 | when :string_literal 58 | walk(*nodes[0]) 59 | when :string_content 60 | nodes[0][1] 61 | # when :void_stmt 62 | # else 63 | # raise key.to_s 64 | end 65 | end 66 | 67 | def sexp 68 | Ripper.sexp(code) 69 | end 70 | end 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /lib/dpl/support/gstore_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | GStore::Client.class_eval do 4 | def sign(str) 5 | digest = OpenSSL::Digest.new('sha1') # use undeprecated constant 6 | Base64.encode64(OpenSSL::HMAC.digest(digest, @secret_key, str)).gsub("\n", '') 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/dpl/support/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Version 4 | InvalidVersion = Class.new(ArgumentError) 5 | InvalidRequire = Class.new(ArgumentError) 6 | 7 | MSGS = { 8 | version: 'Unable to parse version: %p', 9 | require: 'Unable to parse requirement: %p' 10 | }.freeze 11 | 12 | VERSION = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?$/ 13 | REQUIRE = /^(~>|>|>=|=|!=|<=|<) (\d+(?:\.\d+)?(?:\.\d+)?)$/ 14 | 15 | include Comparable 16 | 17 | def initialize(str) 18 | @nums = split(str) || raise(InvalidVersion, MSGS[:version] % str) 19 | end 20 | 21 | def satisfies?(str) 22 | send(*parse(str) || raise(InvalidRequire, MSGS[:require] % str)) 23 | end 24 | 25 | def size 26 | nums.size 27 | end 28 | 29 | def to_a 30 | nums 31 | end 32 | 33 | def to_s 34 | nums.join('.') 35 | end 36 | 37 | def ==(other) 38 | trunc(other.size).to_a == other.to_a 39 | end 40 | 41 | def !=(other) 42 | trunc(other.size).to_a != other.to_a 43 | end 44 | 45 | def <=>(other) 46 | to_a <=> other.to_a 47 | end 48 | 49 | define_method :'~>' do |min| 50 | min = min.trunc(nums.size) 51 | max = min.clone.bump 52 | self >= min && self < max 53 | end 54 | 55 | def bump 56 | ix = nums[1] ? -2 : -1 57 | nums[ix] = nums[ix] + 1 58 | nums[-1] = nums[-1] = 0 if nums[1] 59 | self 60 | end 61 | 62 | def trunc(size) 63 | @nums = nums[0..size - 1] 64 | self 65 | end 66 | 67 | def clone 68 | Version.new(to_s) 69 | end 70 | 71 | private 72 | 73 | attr_reader :nums 74 | 75 | def split(str) 76 | str =~ VERSION && [::Regexp.last_match(1), ::Regexp.last_match(2), ::Regexp.last_match(3)].compact.map(&:to_i) 77 | end 78 | 79 | def parse(str) 80 | op, version = str =~ REQUIRE && [::Regexp.last_match(1), ::Regexp.last_match(2)] 81 | op = '==' if op == '=' 82 | [op, Version.new(version)] if op 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /lib/dpl/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Dpl 4 | VERSION = '2.0.5.4' 5 | end 6 | -------------------------------------------------------------------------------- /spec/dpl/cli_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Cli do 4 | subject { |e| cli.normalize(e.example_group.description.split(' ')) } 5 | 6 | let(:cli) { described_class.new(ctx) } 7 | 8 | describe 'heroku --strategy=api --api_key=key' do 9 | it { is_expected.to eq %w[heroku api --api_key=key] } 10 | end 11 | 12 | describe 'heroku --strategy api --api_key key' do 13 | it { is_expected.to eq %w[heroku api --api_key key] } 14 | end 15 | 16 | describe '--provider=heroku --strategy=api --api_key=key' do 17 | it { is_expected.to eq %w[heroku api --api_key=key] } 18 | end 19 | 20 | describe '--provider heroku --strategy api --api_key key' do 21 | it { is_expected.to eq %w[heroku api --api_key key] } 22 | end 23 | 24 | describe '--api_key=key --provider=heroku --strategy=api' do 25 | it { is_expected.to eq %w[heroku api --api_key=key] } 26 | end 27 | 28 | describe '--api_key key --provider heroku --strategy api' do 29 | it { is_expected.to eq %w[heroku api --api_key key] } 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/dpl/helper/env_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Env::Env do 4 | subject { described_class.new(stringify(env), [*strs, opts]).env(const) } 5 | 6 | let(:const) { Class.new(Dpl::Provider) { opt '--two str' } } 7 | let(:opts) { {} } 8 | 9 | describe 'env var matching prefix and option' do 10 | let(:strs) { [:one] } 11 | let(:env) { { ONE_TWO: 'two' } } 12 | 13 | it { is_expected.to eq two: 'two' } 14 | end 15 | 16 | describe 'env var matching prefix but not option' do 17 | let(:strs) { [:one] } 18 | let(:env) { { ONE_THREE: 'three' } } 19 | 20 | it { is_expected.to be_empty } 21 | end 22 | 23 | describe 'env var matching option but not prefix' do 24 | let(:strs) { [:two] } 25 | let(:env) { { ONE_TWO: 'two' } } 26 | 27 | it { is_expected.to be_empty } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/dpl/helper/github_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Github do 4 | subject { described_class.normalize_filename(from) } 5 | 6 | strs = { 7 | '@': '@', 8 | '+': '+', 9 | '-': '-', 10 | '_': '_', 11 | 'æ': 'ae', 12 | 'ó': 'o', 13 | 'ł': 'l', 14 | 'ð': 'd', 15 | 'ŋ': 'ng', 16 | 'ż': 'z', 17 | '©': '.', 18 | '!': '.', 19 | '#': '.', 20 | '$': '.', 21 | '%': '.', 22 | '&': '.', 23 | "'": '.', 24 | '(': '.', 25 | ')': '.', 26 | ',': '.', 27 | '.': '.', 28 | ';': '.', 29 | '=': '.', 30 | '[': '.', 31 | '\\': '.', 32 | ']': '.', 33 | '^': '.', 34 | '`': '.', 35 | '{': '.', 36 | '}': '.', 37 | '~': '.' 38 | } 39 | 40 | strs.each do |from, to| 41 | describe from.to_s do 42 | let(:from) { from.to_s } 43 | 44 | it { is_expected.to eq to } 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/dpl/helper/zip_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Zip do 4 | subject(:zip) { described_class.new(path, 'test.zip') } 5 | 6 | file 'one' 7 | file 'two' 8 | 9 | describe 'given a file' do 10 | let(:path) { 'one' } 11 | 12 | before { zip.zip } 13 | 14 | it { is_expected.to have_zipped 'test.zip', %w[one] } 15 | end 16 | 17 | describe 'given a directory' do 18 | let(:path) { '.' } 19 | 20 | before { zip.zip } 21 | 22 | it { is_expected.to have_zipped 'test.zip', %w[one two] } 23 | end 24 | 25 | describe 'given a zip file' do 26 | let(:path) { 'one.zip' } 27 | 28 | file 'one.zip' 29 | it { expect(zip.zip.path).to eq 'one.zip' } 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/dpl/provider/zip_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Zip do 4 | subject { Dir.glob('**/*', File::FNM_DOTMATCH).sort } 5 | 6 | let(:zip) { described_class.new(src, dest, opts) } 7 | let(:src) { '.' } 8 | let(:dest) { 'file.zip' } 9 | let(:opts) { {} } 10 | 11 | chdir 'tmp' 12 | file '.dot' 13 | file 'one' 14 | file 'two/one' 15 | file 'two/two' 16 | 17 | before do 18 | zip.zip 19 | rm_r '.dot', 'one', 'two' 20 | system 'unzip file.zip > /dev/null 2>&1' 21 | rm 'file.zip' 22 | end 23 | 24 | describe 'without dot_match' do 25 | it { is_expected.to eq %w[. one two two/one two/two] } 26 | end 27 | 28 | describe 'with dot_match' do 29 | let(:opts) { { dot_match: true } } 30 | 31 | it { is_expected.to eq %w[. .dot one two two/one two/two] } 32 | end 33 | 34 | describe 'src being a subdir' do 35 | let(:src) { 'two' } 36 | 37 | it { is_expected.to eq %w[. one two] } 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/dpl/provider_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe :test do 4 | let!(:const) { Class.new(Dpl::Provider, &body) } 5 | 6 | before { const.register :test } 7 | 8 | describe 'fails during deployment' do 9 | let(:body) { ->(*) { def deploy = error('msg') } } 10 | 11 | it { expect { subject.run }.to raise_error(Dpl::Error, 'msg') } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/dpl/providers/anynines_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Anynines do 4 | let(:args) { |e| %w[--username name --password pass --organization org --space space] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default', record: true do 9 | # it { should have_run %r(wget .*cli.run.pivotal.io.* -qO cf.tgz && tar -zxvf cf.tgz) } 10 | it { is_expected.to have_run './cf api https://api.de.a9s.eu' } 11 | it { is_expected.to have_run '[info] $ ./cf login -u name -p p******************* -o org -s space' } 12 | it { is_expected.to have_run './cf login -u name -p pass -o org -s space' } 13 | it { is_expected.to have_run './cf push' } 14 | it { is_expected.to have_run '[info] $ ./cf logout' } 15 | it { is_expected.to have_run './cf logout' } 16 | it { is_expected.to have_run_in_order } 17 | end 18 | 19 | describe 'given --app_name app_name' do 20 | it { is_expected.to have_run './cf push "app_name"' } 21 | end 22 | 23 | describe 'given --manifest manifest' do 24 | it { is_expected.to have_run './cf push -f manifest' } 25 | end 26 | 27 | describe 'with credentials in env vars', run: false do 28 | let(:args) { %w[--organization org --space space] } 29 | 30 | env ANYNINES_USERNAME: 'name', 31 | ANYNINES_PASSWORD: 'password' 32 | 33 | it { expect { subject.run }.not_to raise_error } 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/dpl/providers/azure_web_apps_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::AzureWebApps do 4 | let(:args) { |e| %w[--site site --username name --password pass] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default' do 9 | it { is_expected.to have_run '[info] Committing changes to git' } 10 | it { is_expected.to have_run '[info] $ git commit -m "Cleanup commit"' } 11 | it { is_expected.to have_run 'git commit -m "Cleanup commit"' } 12 | it { is_expected.to have_run '[info] Deploying to Azure Web App: site' } 13 | it { is_expected.to have_run '[info] $ git push --force --quiet https://name:p*******************@site.scm.azurewebsites.net:443/site.git HEAD:refs/heads/master > /dev/null 2>&1' } 14 | it { is_expected.to have_run 'git push --force --quiet https://name:pass@site.scm.azurewebsites.net:443/site.git HEAD:refs/heads/master > /dev/null 2>&1' } 15 | end 16 | 17 | describe 'given --slot slot' do 18 | it { is_expected.to have_run 'git push --force --quiet https://name:pass@slot.scm.azurewebsites.net:443/site.git HEAD:refs/heads/master > /dev/null 2>&1' } 19 | end 20 | 21 | describe 'given --verbose' do 22 | it { is_expected.to have_run 'git push --force --quiet https://name:pass@site.scm.azurewebsites.net:443/site.git HEAD:refs/heads/master' } 23 | end 24 | 25 | describe 'given ENV vars', run: false do 26 | let(:args) { [] } 27 | 28 | env AZURE_WA_USERNAME: 'name', 29 | AZURE_WA_PASSWORD: 'pass', 30 | AZURE_WA_SITE: 'site', 31 | AZURE_WA_SLOT: 'slot' 32 | 33 | before { subject.run } 34 | 35 | it { is_expected.to have_run 'git push --force --quiet https://name:pass@slot.scm.azurewebsites.net:443/site.git HEAD:refs/heads/master > /dev/null 2>&1' } 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /spec/dpl/providers/boxfuse_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Boxfuse do 4 | let(:args) { |e| %w[--user user --secret 1234] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default' do 9 | it { is_expected.to have_run %r{curl -L https://files.boxfuse.com/.*.tar.gz | tar xz} } 10 | it { is_expected.to have_run '[info] $ boxfuse/boxfuse run -user="user" -secret="1*******************"' } 11 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234"' } 12 | end 13 | 14 | describe 'given --config_file ./file' do 15 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" -configfile=./file' } 16 | end 17 | 18 | describe 'given --configfile ./file' do 19 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" -configfile=./file' } 20 | it { is_expected.to have_deprecated :configfile } 21 | end 22 | 23 | describe 'given --payload payload' do 24 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" -payload="payload"' } 25 | end 26 | 27 | describe 'given --app app' do 28 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" -app="app"' } 29 | end 30 | 31 | describe 'given --env env' do 32 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" -env="env"' } 33 | end 34 | 35 | describe 'given --extra_args args' do 36 | it { is_expected.to have_run 'boxfuse/boxfuse run -user="user" -secret="1234" args' } 37 | end 38 | 39 | describe 'with credentials in env vars', run: false do 40 | env BOXFUSE_USER: 'user', 41 | BOXFUSE_SECRET: '1234' 42 | 43 | it { expect { subject.run }.not_to raise_error } 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /spec/dpl/providers/cargo_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Cargo do 4 | let(:args) { |e| %w[--token 1234] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default' do 9 | it { is_expected.to have_run '[info] $ cargo publish --token="1*******************"' } 10 | it { is_expected.to have_run 'cargo publish --token="1234"' } 11 | end 12 | 13 | describe 'given --allow_dirty' do 14 | it { is_expected.to have_run '[info] $ cargo publish --token="1*******************" --allow-dirty' } 15 | it { is_expected.to have_run 'cargo publish --token="1234" --allow-dirty' } 16 | end 17 | 18 | describe 'with credentials in env vars', run: false do 19 | env CARGO_TOKEN: '1234' 20 | it { expect { subject.run }.not_to raise_error } 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/dpl/providers/cloud66_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Cloud66 do 4 | let(:url) { 'https://hook.io/' } 5 | 6 | before { stub_request(:post, url).to_return(status: 200) } 7 | before { |c| subject.run if run?(c) } 8 | 9 | describe 'given --redeployment_hook https://hook.io/' do 10 | it { assert_requested :post, url } 11 | end 12 | 13 | describe 'with credentials in env vars', run: false do 14 | env CLOUD66_REDEPLOYMENT_HOOK: 'https://hook.io/' 15 | it { expect { subject.run }.not_to raise_error } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/dpl/providers/cloudfiles_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Cloudfiles do 4 | let(:storage) { Fog::Storage.new(provider: 'rackspace', rackspace_username: 'user', rackspace_api_key: 'key', rackspace_region: 'ord') } 5 | let(:args) { |e| %w[--username user --api_key key --region ord --container name] + args_from_description(e) } 6 | let(:dirs) { storage.directories } 7 | 8 | file :one 9 | file :two 10 | 11 | before do 12 | Fog.mock! 13 | dirs.create(key: 'name') 14 | end 15 | 16 | before { |c| subject.run if run?(c) } 17 | 18 | describe 'by default' do 19 | it { expect(dirs.get('name').files.get('one').key).to eq 'one' } 20 | it { expect(dirs.get('name').files.get('two').key).to eq 'two' } 21 | end 22 | 23 | describe 'given --glob one' do 24 | it { expect(dirs.get('name').files.get('one').key).to eq 'one' } 25 | it { expect(dirs.get('name').files.get('two')).to be_nil } 26 | end 27 | 28 | describe 'with credentials in env vars', run: false do 29 | let(:args) { |_e| %w[--region ord --container name] } 30 | 31 | env CLOUDFILES_USERNAME: 'user', 32 | CLOUDFILES_API_KEY: 'key' 33 | 34 | it { expect { subject.run }.not_to raise_error } 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /spec/dpl/providers/cloudfoundry_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Cloudfoundry do 4 | let(:args) { |e| %w[--username name --password pass --organization org --space space] + args_from_description(e) } 5 | 6 | file 'manifest.yml' 7 | file 'other.yml' 8 | 9 | before { |c| subject.run if run?(c) } 10 | 11 | describe 'by default', record: true do 12 | it { is_expected.to have_run(/wget .*cli.run.pivotal.io.* -qO cf.tgz && tar -zxvf cf.tgz/) } 13 | it { is_expected.to have_run './cf api https://api.run.pivotal.io' } 14 | it { is_expected.to have_run './cf login -u name -p pass -o org -s space' } 15 | it { is_expected.to have_run './cf push' } 16 | it { is_expected.to have_run './cf logout' } 17 | it { is_expected.to have_run_in_order } 18 | end 19 | 20 | describe 'given --api api.io' do 21 | it { is_expected.to have_run './cf api api.io' } 22 | end 23 | 24 | describe 'given --app_name app_name' do 25 | it { is_expected.to have_run './cf push "app_name"' } 26 | end 27 | 28 | describe 'given --manifest other.yml' do 29 | it { is_expected.to have_run './cf push -f other.yml' } 30 | end 31 | 32 | describe 'given --deployment_strategy rolling' do 33 | it { is_expected.to have_run './cf push --strategy rolling' } 34 | end 35 | 36 | describe 'given --v3' do 37 | it { is_expected.to have_run './cf v3-push' } 38 | end 39 | 40 | describe 'with credentials in env vars', run: false do 41 | let(:args) { %w[--api api.io --organization org --space space] } 42 | 43 | env CLOUDFOUNDRY_USERNAME: 'name', 44 | CLOUDFOUNDRY_PASSWORD: 'password' 45 | 46 | it { expect { subject.run }.not_to raise_error } 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /spec/dpl/providers/datica_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Datica do 4 | let(:args) { |e| %w[--target target] + args_from_description(e) } 5 | 6 | env TRAVIS_REPO_SLUG: 'repo', 7 | TRAVIS_BRANCH: 'branch', 8 | TRAVIS_BUILD_NUMBER: '1', 9 | TRAVIS_COMMIT: 'commit' 10 | 11 | before { |c| subject.run if run?(c) } 12 | 13 | describe 'by default' do 14 | it { is_expected.to have_run 'git checkout HEAD' } 15 | it { is_expected.to have_run 'git add . --all --force' } 16 | it { is_expected.to have_run 'git commit -m "Build #1 (commit) of repo@branch" --quiet' } 17 | it { is_expected.to have_run 'git push --force target HEAD:master' } 18 | end 19 | 20 | describe 'using alias registry key :catalyze', run: false do 21 | let(:provider) { :catalyze } 22 | 23 | before { subject.run } 24 | 25 | it { is_expected.to have_run 'git push --force target HEAD:master' } 26 | end 27 | 28 | describe 'with credentials in env vars', run: false do 29 | let(:args) { [] } 30 | 31 | env DATICA_TARGET: 'target' 32 | it { expect { subject.run }.not_to raise_error } 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /spec/dpl/providers/firebase_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Firebase do 4 | let(:args) { |e| %w[--token token] + args_from_description(e) } 5 | 6 | file 'firebase.json' 7 | 8 | before { |c| subject.run if run?(c) } 9 | 10 | describe 'by default' do 11 | it { is_expected.to have_run '[npm:install] firebase-tools@^6.3 (firebase)' } 12 | it { is_expected.to have_run 'firebase deploy --non-interactive --token="token"' } 13 | end 14 | 15 | describe 'given --project name' do 16 | it { is_expected.to have_run 'firebase deploy --non-interactive --project="name" --token="token"' } 17 | end 18 | 19 | describe 'given --message msg' do 20 | it { is_expected.to have_run 'firebase deploy --non-interactive --message="msg" --token="token"' } 21 | end 22 | 23 | describe 'given --only only' do 24 | it { is_expected.to have_run 'firebase deploy --non-interactive --token="token" --only="only"' } 25 | end 26 | 27 | describe 'given --force' do 28 | it { is_expected.to have_run 'firebase deploy --non-interactive --token="token" --force' } 29 | end 30 | 31 | describe 'missing firebase.json', run: false do 32 | before { rm 'firebase.json' } 33 | 34 | it { expect { subject.run }.to raise_error 'Missing firebase.json' } 35 | end 36 | 37 | describe 'adds node_modules/.bin to $PATH' do 38 | it { expect(ENV['PATH']).to include 'node_modules/.bin' } 39 | end 40 | 41 | describe 'with credentials in env vars', run: false do 42 | let(:args) { [] } 43 | 44 | env FIREBASE_TOKEN: 'token' 45 | it { expect { subject.run }.not_to raise_error } 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/dpl/providers/flynn_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Flynn do 4 | let(:args) { %w[--git https://flynn.io/target.git] } 5 | 6 | before { subject.run } 7 | 8 | describe 'by default', record: true do 9 | it { is_expected.to have_run(/git config user.email/) } 10 | it { is_expected.to have_run(/git config user.name/) } 11 | it { is_expected.to have_run 'git fetch origin $TRAVIS_BRANCH --unshallow' } 12 | it { is_expected.to have_run 'git push https://flynn.io/target.git HEAD:refs/heads/master -f' } 13 | it { is_expected.to have_run_in_order } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dpl/providers/gleis_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Gleis do 4 | let(:args) { |e| %w[--app app --username user --password pass] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default', record: true do 9 | it { is_expected.to have_run '[info] $ gleis auth login user p******************* --skip-keygen' } 10 | it { is_expected.to have_run 'gleis auth login user pass --skip-keygen' } 11 | it { is_expected.to have_run '[info] $ gleis auth key add ~/.dpl/id_rsa.pub dpl_deploy_key' } 12 | it { is_expected.to have_run 'gleis auth key add ~/.dpl/id_rsa.pub dpl_deploy_key' } 13 | it { is_expected.to have_run '[info] $ gleis app git -a app -q' } 14 | it { is_expected.to have_run 'gleis app git -a app -q' } 15 | it { is_expected.to have_run '[info] $ gleis app status -a app' } 16 | it { is_expected.to have_run 'gleis app status -a app' } 17 | it { is_expected.to have_run '[info] $ git push -f captured_stdout HEAD:refs/heads/master' } 18 | it { is_expected.to have_run 'git push -f captured_stdout HEAD:refs/heads/master' } 19 | it { is_expected.to have_run_in_order } 20 | end 21 | 22 | describe 'given --key_name key_name' do 23 | it { is_expected.to have_run '[info] $ gleis auth key add ~/.dpl/id_rsa.pub key_name' } 24 | it { is_expected.to have_run 'gleis auth key add ~/.dpl/id_rsa.pub key_name' } 25 | end 26 | 27 | describe 'given --verbose' do 28 | it { is_expected.to have_run 'git push -v -f captured_stdout HEAD:refs/heads/master' } 29 | end 30 | 31 | describe 'with credentials in env vars', run: false do 32 | let(:args) { %w[--app app] } 33 | 34 | env GLEIS_USERNAME: 'user', 35 | GLEIS_PASSWORD: 'pass' 36 | it { expect { subject.run }.not_to raise_error } 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /spec/dpl/providers/hackage_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Hackage do 4 | let(:args) { |e| %w[--username user --password pass] + args_from_description(e) } 5 | 6 | file 'dist/one.tar.gz' 7 | file 'dist/two.tar.gz' 8 | 9 | before { |c| subject.run if run?(c) } 10 | 11 | describe 'by default', record: true do 12 | it { is_expected.to have_run 'cabal check' } 13 | it { is_expected.to have_run 'cabal sdist' } 14 | it { is_expected.to have_run 'cabal upload --username="user" --password="pass" dist/one.tar.gz' } 15 | it { is_expected.to have_run 'cabal upload --username="user" --password="pass" dist/two.tar.gz' } 16 | it { is_expected.to have_run_in_order } 17 | end 18 | 19 | describe 'given --publish' do 20 | it { is_expected.to have_run 'cabal upload --publish --username="user" --password="pass" dist/one.tar.gz' } 21 | end 22 | 23 | describe 'with credentials in env vars', run: false do 24 | let(:args) { [] } 25 | 26 | env HACKAGE_USERNAME: 'user', 27 | HACKAGE_PASSWORD: 'pass' 28 | it { expect { subject.run }.not_to raise_error } 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/dpl/providers/hephy_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Hephy do 4 | let(:args) { |e| %w[--controller hephy.hephyapps.com --username user --password pass --app app] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default', record: true do 9 | it { is_expected.to have_run 'curl -sSL https://raw.githubusercontent.com/teamhephy/workflow-cli/master/install-v2.sh | bash -x -s stable && mv deis ~/.dpl' } 10 | it { is_expected.to have_run 'deis login hephy.hephyapps.com --username=user --password=pass' } 11 | it { is_expected.to have_run 'deis keys:add ~/.dpl/id_rsa.pub' } 12 | it { is_expected.to have_run %r{dpl/.dpl/git-ssh hephy-builder.hephyapps.com -p 2222 2>&1 | grep -c 'PTY allocation request failed' > /dev/null} } 13 | it { is_expected.to have_run %r{git push.*ssh://git@hephy-builder.hephyapps.com:2222/app.git} } 14 | it { is_expected.to have_run 'deis keys:remove machine_name' } 15 | it { is_expected.to have_run_in_order } 16 | end 17 | 18 | describe 'given --cli_version v2.7.0' do 19 | it { is_expected.to have_run %r{curl -sSL https://.*install-v2.sh | bash -x -s v2.7.0} } 20 | end 21 | 22 | describe 'given --verbose' do 23 | it { is_expected.to have_run %r{git push -v ssh://git@hephy-builder.hephyapps.com:2222/app.git} } 24 | end 25 | 26 | describe 'with credentials in env vars', run: false do 27 | let(:args) { |_e| %w[--controller hephy.hephyapps.com --app app] } 28 | 29 | env HEPHY_USERNAME: 'user', 30 | HEPHY_PASSWORD: 'pass' 31 | it { expect { subject.run }.not_to raise_error } 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/dpl/providers/launchpad_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Launchpad do 4 | let(:args) { %w[--slug ~user/project/branch --oauth_token token --oauth_token_secret secret] } 5 | let(:url) { 'https://api.launchpad.net/1.0/~user/project/branch/+code-import' } 6 | let(:body) { 'ws.op=requestImport' } 7 | 8 | let(:auth) do 9 | / 10 | OAuth\ oauth_consumer_key="Travis%20Deploy",.* 11 | oauth_nonce=".*",.* 12 | oauth_signature="%26secret",.* 13 | oauth_signature_method="PLAINTEXT",.* 14 | oauth_timestamp=".*",.* 15 | oauth_token="token",.* 16 | oauth_version="1\.0" 17 | /x 18 | end 19 | 20 | before { stub_request(:post, /.*/) } 21 | before { |c| subject.run if run?(c) } 22 | 23 | describe 'by default' do 24 | it { is_expected.to have_requested(:post, url).with(body:, headers: { Authorization: auth }) } 25 | end 26 | 27 | describe 'with credentials in env vars', run: false do 28 | let(:args) { %w[--slug ~user/project/branch --oauth_token token] } 29 | 30 | env LAUNCHPAD_OAUTH_TOKEN_SECRET: 'secret' 31 | it { expect { subject.run }.not_to raise_error } 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/dpl/providers/netlify_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Netlify do 4 | let(:args) { |e| %w[--auth token --site id] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default' do 9 | it { is_expected.to have_run '[npm:install] netlify-cli (netlify)' } 10 | it { is_expected.to have_run 'netlify deploy --site="id" --auth="token"' } 11 | end 12 | 13 | describe 'given --dir ./dir' do 14 | it { is_expected.to have_run 'netlify deploy --site="id" --auth="token" --dir="./dir"' } 15 | end 16 | 17 | describe 'given --functions ./functions' do 18 | it { is_expected.to have_run 'netlify deploy --site="id" --auth="token" --functions="./functions"' } 19 | end 20 | 21 | describe 'given --message message' do 22 | it { is_expected.to have_run 'netlify deploy --site="id" --auth="token" --message="message"' } 23 | end 24 | 25 | describe 'given --prod' do 26 | it { is_expected.to have_run 'netlify deploy --site="id" --auth="token" --prod' } 27 | end 28 | 29 | describe 'with credentials in env vars', run: false do 30 | let(:args) { %w[--site id] } 31 | 32 | env NETLIFY_AUTH: 'token' 33 | it { expect { subject.run }.not_to raise_error } 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/dpl/providers/nuget_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Nuget do 4 | let(:args) { |e| %w[--api_key secret --registry url] + args_from_description(e) } 5 | 6 | before { subject.run } 7 | 8 | describe 'by default', record: true do 9 | it { is_expected.to have_run '[info] Setting the build environment up for the deployment' } 10 | it { is_expected.to have_run '[info] Authenticating with API key s*******************' } 11 | it { is_expected.to have_run '[info] Pushing package *.nupkg to url' } 12 | it { is_expected.to have_run '[info] $ dotnet nuget push *.nupkg -k s******************* -s url' } 13 | it { is_expected.to have_run 'dotnet nuget push *.nupkg -k secret -s url' } 14 | it { is_expected.to have_run_in_order } 15 | end 16 | 17 | describe 'given --src other.nupkg' do 18 | it { is_expected.to have_run 'dotnet nuget push other.nupkg -k secret -s url' } 19 | end 20 | 21 | describe 'given --no_symbols' do 22 | it { is_expected.to have_run 'dotnet nuget push *.nupkg -k secret -s url --no-symbols' } 23 | end 24 | 25 | describe 'given --skip_duplicate' do 26 | it { is_expected.to have_run 'dotnet nuget push *.nupkg -k secret -s url --skip-duplicate' } 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/dpl/providers/openshift_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Openshift do 4 | let(:args) { |e| %w[--server server --token token --project project] + args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'by default', record: true do 9 | it { is_expected.to have_run 'curl https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1/linux/oc.tar.gz | tar xz' } 10 | it { is_expected.to have_run './oc login --token=token --server=server' } 11 | it { is_expected.to have_run './oc project project' } 12 | it { is_expected.to have_run './oc start-build dpl --follow --commit sha' } 13 | it { is_expected.to have_run_in_order } 14 | end 15 | 16 | describe 'given --app other' do 17 | it { is_expected.to have_run './oc start-build other --follow --commit sha' } 18 | end 19 | 20 | describe 'with credentials in env vars', run: false do 21 | let(:args) { %w[--server server --project project] } 22 | 23 | env OPENSHIFT_TOKEN: 'token' 24 | it { expect { subject.run }.not_to raise_error } 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/dpl/providers/puppetforge_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Puppetforge do 4 | let(:args) { |e| %w[--username user --password pass] + args_from_description(e) } 5 | let(:face) { double(build: nil) } 6 | let(:forge) { double(username: 'user', push!: nil) } 7 | 8 | file 'metadata.json', JSON.dump(name: 'author-module') 9 | 10 | before do 11 | allow(Blacksmith::Forge).to receive(:new).and_return(forge) 12 | allow(Puppet::Face).to receive(:[]).and_return(face) 13 | end 14 | 15 | before { |c| subject.run if run?(c) } 16 | 17 | describe 'by default' do 18 | it { is_expected.to have_run '[info] Uploading to Puppet Forge user/module' } 19 | it { expect(Blacksmith::Forge).to have_received(:new).with('user', 'pass', 'https://forgeapi.puppetlabs.com/') } 20 | it { expect(forge).to have_received :push! } 21 | end 22 | 23 | describe 'with credentials in env vars', run: false do 24 | let(:args) { [] } 25 | 26 | env PUPPETFORGE_USERNAME: 'user', 27 | PUPPETFORGE_PASSWORD: 'pass' 28 | it { expect { subject.run }.not_to raise_error } 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/dpl/providers/scalingo_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Scalingo do 4 | let(:args) { |e| args_from_description(e) } 5 | 6 | before { |c| subject.run if run?(c) } 7 | 8 | describe 'given --api_token token', record: true do 9 | it { is_expected.to have_run %r{curl --remote-name --location https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz} } 10 | it { is_expected.to have_run %r{timeout 60 ./scalingo login --api-token token} } 11 | it { is_expected.to have_run 'timeout 60 ./scalingo keys-add dpl_tmp_key ~/.dpl/id_rsa.pub' } 12 | it { is_expected.to have_run 'git push scalingo-dpl HEAD:master -f' } 13 | it { is_expected.to have_run 'timeout 60 ./scalingo keys-remove dpl_tmp_key' } 14 | it { is_expected.to have_run_in_order } 15 | end 16 | 17 | describe 'given --api_key key' do 18 | it { is_expected.to have_run %r{timeout 60 ./scalingo login --api-token key} } 19 | end 20 | 21 | describe 'given --username user --password pass', record: true do 22 | it { is_expected.to have_run %r{echo -e "user\npass" | timeout 60 ./scalingo login} } 23 | end 24 | 25 | describe 'given --api_token key --branch branch' do 26 | it { is_expected.to have_run 'git push scalingo-dpl HEAD:branch -f' } 27 | end 28 | 29 | describe 'given --api_token key --app app' do 30 | it { is_expected.to have_run %r{./scalingo --app app git-setup --remote scalingo-dpl} } 31 | end 32 | 33 | describe 'given --api_token key --app app --remote remote' do 34 | it { is_expected.to have_run %r{./scalingo --app app git-setup --remote remote} } 35 | end 36 | 37 | describe 'invalid credentials', run: false do 38 | it { expect { subject.run }.to raise_error 'Missing options: api_token, or username and password' } 39 | end 40 | 41 | describe 'with credentials in env vars', run: false do 42 | let(:args) { [] } 43 | 44 | env SCALINGO_API_TOKEN: 'token' 45 | it { expect { subject.run }.not_to raise_error } 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/dpl/providers/script_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Script do 4 | let(:args) { |e| args_from_description(e) } 5 | 6 | before { subject.run } 7 | 8 | describe 'given --script ./script' do 9 | it { is_expected.to have_run './script' } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dpl/providers/snap_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Snap do 4 | let(:args) { |e| args_from_description(e) + %w[--token token] } 5 | 6 | file 'snap' 7 | 8 | before { |c| subject.run if run?(c) } 9 | 10 | describe 'given --snap ./snap', record: true do 11 | it { is_expected.to have_run '[apt:get] snapd (snap)' } 12 | it { is_expected.to have_run 'sudo snap install snapcraft --classic' } 13 | it { is_expected.to have_run 'echo "token" | snapcraft login --with -' } 14 | it { is_expected.to have_run 'snapcraft push ./snap --release=edge' } 15 | it { is_expected.to have_run_in_order } 16 | end 17 | 18 | describe 'given --snap ./sn*' do 19 | it { is_expected.to have_run 'snapcraft push ./snap --release=edge' } 20 | end 21 | 22 | describe 'given --snap ./snap --channel channel' do 23 | it { is_expected.to have_run 'snapcraft push ./snap --release=channel' } 24 | end 25 | 26 | describe 'given --snap ./snap', run: false do 27 | let(:args) { |e| args_from_description(e) } 28 | 29 | env SNAP_TOKEN: 'token' 30 | 31 | before { subject.run } 32 | 33 | it { is_expected.to have_run 'echo "token" | snapcraft login --with -' } 34 | end 35 | 36 | describe 'given --snap ./snap', run: false do 37 | before { rm 'snap' } 38 | 39 | it { expect { subject.run }.to raise_error 'No snap found matching ./snap' } 40 | end 41 | 42 | describe 'given --snap ./sn*', run: false do 43 | file 'snap-1' 44 | file 'snap-2' 45 | it { expect { subject.run }.to raise_error 'Multiple snaps found matching ./sn*: ./snap, ./snap-1, ./snap-2' } 46 | end 47 | 48 | describe 'with credentials in env vars', run: false do 49 | let(:args) { %w[--snap ./snap] } 50 | 51 | env SNAP_TOKEN: 'token' 52 | it { expect { subject.run }.not_to raise_error } 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /spec/dpl/providers/surge_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Surge do 4 | let(:args) { |e| args_from_description(e) } 5 | let(:cwd) { File.expand_path('.') } 6 | 7 | before { stub_request(:get, %r{npmjs.com/surge/latest}).to_return(body: '{"_nodeVersion": "8.8.0"}') } 8 | 9 | describe 'given --login login --token token --domain domain', record: true do 10 | before { subject.run } 11 | 12 | it { is_expected.to have_run '[validate:runtime] node_js (>= 8.8.1)' } 13 | it { is_expected.to have_run '[npm:install] surge (surge)' } 14 | it { is_expected.to have_run "surge #{cwd} domain" } 15 | it { is_expected.to have_run_in_order } 16 | it { is_expected.to have_env SURGE_LOGIN: 'login' } 17 | it { is_expected.to have_env SURGE_TOKEN: 'token' } 18 | end 19 | 20 | describe 'given --login login --token token' do 21 | file :CNAME 22 | before { subject.run } 23 | 24 | it { is_expected.to have_run "surge #{cwd}" } 25 | end 26 | 27 | describe 'given --login login --token token' do 28 | it { expect { subject.run }.to raise_error(/Please set the domain/) } 29 | end 30 | 31 | describe 'given --login login --token token --domain domain --project ./path' do 32 | dir 'path' 33 | before { subject.run } 34 | 35 | it { is_expected.to have_run "surge #{cwd}/path domain" } 36 | end 37 | 38 | describe 'given --login login --token token --domain domain --project ./path' do 39 | it { expect { subject.run }.to raise_error "#{cwd}/path is not a directory" } 40 | end 41 | 42 | describe 'given --domain domain' do 43 | env SURGE_LOGIN: 'login', SURGE_TOKEN: 'token' 44 | before { subject.run } 45 | 46 | it { is_expected.to have_run "surge #{cwd} domain" } 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /spec/dpl/providers/testfairy_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Testfairy do 4 | let(:args) { |e| %w[--api_key key --app_file file] + args_from_description(e) } 5 | 6 | file 'file' 7 | 8 | before { stub_request(:post, 'https://upload.testfairy.com/api/upload').and_return(body: JSON.dump(status: 'success')) } 9 | before { |c| subject.run unless c.metadata[:example_group][:run].is_a?(FalseClass) } 10 | 11 | describe 'by default' do 12 | it { is_expected.to have_run(/Uploading to TestFairy:/) } 13 | it { is_expected.to have_run(/"apk_file": "file"/) } 14 | end 15 | 16 | describe 'given --symbols_file file' do 17 | it { is_expected.to have_run(/"symbols_file": "file"/) } 18 | end 19 | 20 | describe 'given --testers_groups one,two' do 21 | it { is_expected.to have_run(/"testers-groups": "one,two"/) } 22 | end 23 | 24 | describe 'given --notify' do 25 | it { is_expected.to have_run(/"notify": "on"/) } 26 | end 27 | 28 | describe 'given --auto_update' do 29 | it { is_expected.to have_run(/"auto-update": "on"/) } 30 | end 31 | 32 | describe 'given --advanced_options one,two' do 33 | it { is_expected.to have_run(/"advanced-options": "one,two"/) } 34 | end 35 | 36 | describe 'with credentials in env vars', run: false do 37 | let(:args) { %w[--app_file file] } 38 | 39 | env TESTFAIRY_API_KEY: 'key' 40 | it { expect { subject.run }.not_to raise_error } 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /spec/dpl/providers/transifex_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | describe Dpl::Providers::Transifex do 4 | let(:args) { |e| %w[--username user --password pass] + args_from_description(e) } 5 | let(:rc) { File.read('./home/.transifexrc') } 6 | 7 | before { |c| subject.run if run?(c) } 8 | 9 | describe 'by default', record: true do 10 | it { is_expected.to have_run '[pip:install] transifex-client (tx, >=0.11)' } 11 | it { is_expected.to have_run 'tx status' } 12 | it { is_expected.to have_run 'tx push --source --no-interactive' } 13 | it { is_expected.to have_run_in_order } 14 | 15 | it do 16 | expect(subject).to have_written '~/.transifexrc', sq(<<-RC) 17 | [https://www.transifex.com] 18 | hostname = https://www.transifex.com 19 | username = user 20 | password = pass 21 | RC 22 | end 23 | end 24 | 25 | describe 'given --cli_version >=0.22' do 26 | it { is_expected.to have_run '[pip:install] transifex-client (tx, >=0.22)' } 27 | end 28 | 29 | describe 'given --hostname other.com' do 30 | it { expect(rc).to include 'hostname = https://other.com' } 31 | end 32 | 33 | describe 'given --hostname https://other.com' do 34 | it { expect(rc).to include 'hostname = https://other.com' } 35 | end 36 | 37 | describe 'with credentials in env vars', run: false do 38 | let(:args) { [] } 39 | 40 | env TRANSIFEX_USERNAME: 'user', 41 | TRANSIFEX_PASSWORD: 'pass' 42 | it { expect { subject.run }.not_to raise_error } 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /spec/dpl/support/gems_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'dpl/support/gems' 4 | -------------------------------------------------------------------------------- /spec/fixtures/bintray/descriptor.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "name": "name", 4 | "repo": "repo", 5 | "subject": "user", 6 | "desc": "desc", 7 | "website_url": "website_url", 8 | "issue_tracker_url": "issue_tracker_url", 9 | "vcs_url": "vcs_url", 10 | "github_use_tag_release_notes": true, 11 | "github_release_notes_file": "RELEASE.txt", 12 | "licenses": ["MIT"], 13 | "labels": ["one", "two", "three"], 14 | "public_download_numbers": false, 15 | "public_stats": false, 16 | "attributes": [ 17 | { "name": "foo", "values" : ["foo"], "type": "string" }, 18 | { "name": "bar", "values" : [1], "type": "number" } 19 | ] 20 | }, 21 | "version": { 22 | "name": "0.5", 23 | "desc": "desc", 24 | "released": "2015-01-01", 25 | "vcs_tag": "0.5", 26 | "attributes": [ 27 | { "name": "bar", "values" : ["bar"], "type": "string" }, 28 | { "name": "baz", "values" : [2], "type": "number" } 29 | ], 30 | "gpgSign": true 31 | }, 32 | "files": [ 33 | { 34 | "includePattern": "build/bin(.*)*/(.*\\.gem)", 35 | "excludePattern": ".*/do-not-deploy/.*", 36 | "uploadPattern": "gems/$2", 37 | "listInDownloads": true 38 | }, 39 | { 40 | "includePattern": "build/doc/(.*)", 41 | "uploadPattern": "doc/$1" 42 | } 43 | ], 44 | "publish": true 45 | } 46 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/app_env_multi.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolver": { 3 | "errors": [ 4 | 5 | ], 6 | "suggestions": [ 7 | 8 | ], 9 | "matches": [ 10 | { 11 | "id": 6, 12 | "environment": { 13 | "id": 7, 14 | "ssh_username": "turkey", 15 | "name": "giblets", 16 | "instances_count": 7, 17 | "app_server_stack_name": "nginx_mongrel", 18 | "load_balancer_ip_address": "127.0.0.0", 19 | "framework_env": "production", 20 | "account": { 21 | "id": 7, 22 | "name": "main" 23 | } 24 | }, 25 | "app": { 26 | "id": 7, 27 | "name": "rails232app", 28 | "repository_uri": "user@git.host:path/to/repo.git", 29 | "app_type_id": null, 30 | "account": { 31 | "id": 7, 32 | "name": "main" 33 | } 34 | } 35 | }, 36 | { 37 | "id": 7, 38 | "environment": { 39 | "id": 8, 40 | "ssh_username": "turkey", 41 | "name": "giblets", 42 | "instances_count": 7, 43 | "app_server_stack_name": "nginx_mongrel", 44 | "load_balancer_ip_address": "127.0.0.0", 45 | "framework_env": "production", 46 | "account": { 47 | "id": 8, 48 | "name": "account_2" 49 | } 50 | }, 51 | "app": { 52 | "id": 8, 53 | "name": "rails232app", 54 | "repository_uri": "user@git.host:path/to/repo.git", 55 | "app_type_id": null, 56 | "account": { 57 | "id": 8, 58 | "name": "account_2" 59 | } 60 | } 61 | } 62 | ] 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/app_env_none.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolver": { 3 | "errors": [ 4 | "No environment found matching \"notfound\"." 5 | ], 6 | "suggestions": [ 7 | 8 | ], 9 | "matches": [ 10 | 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/app_env_one.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolver": { 3 | "errors": [ 4 | 5 | ], 6 | "suggestions": [ 7 | 8 | ], 9 | "matches": [ 10 | { 11 | "id": 6, 12 | "environment": { 13 | "id": 7, 14 | "ssh_username": "turkey", 15 | "name": "giblets", 16 | "instances_count": 7, 17 | "app_server_stack_name": "nginx_mongrel", 18 | "load_balancer_ip_address": "127.0.0.0", 19 | "framework_env": "production", 20 | "account": { 21 | "id": 7, 22 | "name": "main" 23 | } 24 | }, 25 | "app": { 26 | "id": 7, 27 | "name": "rails232app", 28 | "repository_uri": "user@git.host:path/to/repo.git", 29 | "app_type_id": null, 30 | "account": { 31 | "id": 7, 32 | "name": "main" 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/auth.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_token": "token" 3 | } 4 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/deploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "deployment": { 3 | "id": 2, 4 | "ref": "master", 5 | "resolved_ref": "resolved-master", 6 | "commit": "abcdef1234abcdef1234abcdef1234abcdef1234", 7 | "user_name": "Multiple Ambiguous Accounts", 8 | "migrate_command": "rake migrate", 9 | "created_at": "2019-05-08T22:33:08+02:00", 10 | "finished_at": null, 11 | "successful": null, 12 | "serverside_version": "2.0.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/deployment.json: -------------------------------------------------------------------------------- 1 | { 2 | "deployment": { 3 | "id": 2, 4 | "ref": "master", 5 | "resolved_ref": "resolved-master", 6 | "commit": "abcdef1234abcdef1234abcdef1234abcdef1234", 7 | "user_name": "Multiple Ambiguous Accounts", 8 | "migrate_command": "rake migrate", 9 | "created_at": "2019-05-08T22:33:08+02:00", 10 | "finished_at": "2019-05-08T22:33:08+02:00", 11 | "successful": true, 12 | "serverside_version": "2.0.3" 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /spec/fixtures/engineyard/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "user": { 3 | "id": 1, 4 | "name": "User Name", 5 | "email": "test@test.test" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | ENV.delete('TRAVIS_TAG') 4 | 5 | require 'coveralls' 6 | Coveralls.wear! if ENV['TRAVIS'] 7 | 8 | require 'webmock/rspec' 9 | require 'dpl' 10 | require 'support' 11 | 12 | RSpec.configure do |c| 13 | c.include Support::Cl 14 | c.include Support::Ctx 15 | c.include Support::Env 16 | c.include Support::File 17 | c.include Support::Fixtures 18 | c.include Support::Helpers 19 | c.include Support::Matchers 20 | c.include Support::Matchers::RecordCmds, record: true 21 | c.include Support::Now 22 | c.include Support::Require 23 | 24 | c.before { rm_rf '/tmp/dpl' } 25 | c.before { chdir '/tmp/dpl' } 26 | end 27 | -------------------------------------------------------------------------------- /spec/support.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'support/cl' 4 | require 'support/ctx' 5 | require 'support/env' 6 | require 'support/file' 7 | require 'support/fixtures' 8 | require 'support/gemfile' 9 | require 'support/helpers' 10 | require 'support/matchers' 11 | require 'support/now' 12 | require 'support/require' 13 | -------------------------------------------------------------------------------- /spec/support/cl.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Cl 5 | module Sq 6 | # Beloved squiggly heredocs did not exist in Ruby 2.1.0, which we still 7 | # want to support, so let's give kudos with this method in the meantime. 8 | def sq(str) 9 | width = str =~ /( *)\S/ && ::Regexp.last_match(1).size 10 | str.lines.map { |line| line.gsub(/^ {#{width}}/, '') }.join 11 | end 12 | end 13 | 14 | def self.included(base) 15 | base.let(:provider) do 16 | next described_class if described_class.is_a?(Symbol) 17 | next described_class.registry_key if described_class.registry_key 18 | 19 | described_class.name.split('::').last.downcase 20 | end 21 | base.let(:args) { |e| args_from_description(e) } 22 | base.subject { cmd } 23 | base.extend Sq 24 | end 25 | 26 | include Sq 27 | 28 | def args_from_description(e) 29 | strs = e.example_group.parent_groups.map(&:description) 30 | args = strs.map do |str| 31 | next unless str.include?('given -') 32 | 33 | str = str.sub(/.*given /, '').sub(/\(.*/, '').strip 34 | strs = str.split(/\s(?=(?:[^"]|"[^"]*")*$)/) 35 | strs.map { |str| str.gsub('"', '') } 36 | end 37 | args.flatten.compact 38 | end 39 | 40 | def runner(args = nil) 41 | args ||= respond_to?(:args) ? self.args : args_from_description 42 | args = [provider.to_s, *args] 43 | Dpl::Cli.new(ctx, 'dpl').runner(args) 44 | end 45 | 46 | def cmd(args = nil) 47 | runner(args).cmd 48 | end 49 | 50 | def run 51 | runner.run 52 | end 53 | 54 | def run?(c) 55 | not c.metadata[:example_group][:run].is_a?(FalseClass) 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /spec/support/ctx.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Ctx 5 | def self.included(base) 6 | base.let(:ctx) { Dpl::Ctx::Test.new } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/support/env.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Env 5 | def self.included(base) 6 | base.send(:extend, ClassMethods) 7 | end 8 | 9 | module ClassMethods 10 | def env(vars) 11 | prepend_before { define_env(vars) } 12 | end 13 | end 14 | 15 | def define_env(vars) 16 | vars.each do |key, value| 17 | ENV[key.to_s] = value.is_a?(Proc) ? instance_eval(&value).to_s : value.to_s 18 | end 19 | self.class.after { undefine_env(vars) } 20 | end 21 | 22 | def undefine_env(vars) 23 | vars.each { |key, _| ENV.delete(key.to_s) } 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/support/file.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'fileutils' 4 | require 'yaml' 5 | 6 | module Support 7 | module File 8 | def self.included(base) 9 | base.send(:extend, ClassMethods) 10 | end 11 | 12 | module ClassMethods 13 | def file(*args) 14 | before { file(*args) } 15 | end 16 | 17 | def dir(name) 18 | before { dir(name) } 19 | end 20 | 21 | def chdir(dir) 22 | before do 23 | @cwd = Dir.pwd 24 | chdir(dir) 25 | end 26 | 27 | after do 28 | chdir(@cwd) 29 | rm_r(dir) 30 | end 31 | end 32 | 33 | def rm(_path) 34 | after { chdir(dir) } 35 | end 36 | 37 | def yaml(obj) 38 | YAML.dump(obj) 39 | end 40 | end 41 | 42 | def file(path, content = '') 43 | path = path.to_s 44 | FileUtils.mkdir_p(::File.dirname(path)) 45 | ::File.open(path, 'w+') { |f| f.write(content) } 46 | end 47 | 48 | def dir(dir) 49 | FileUtils.mkdir_p(dir) 50 | end 51 | 52 | def chdir(name) 53 | dir(name) 54 | Dir.chdir(name) 55 | end 56 | 57 | def rm_r(*paths) 58 | paths.each { |path| FileUtils.rm_r(path) } 59 | end 60 | alias rm rm_r 61 | 62 | def rm_rf(*paths) 63 | paths.each { |path| FileUtils.rm_rf(path) } 64 | end 65 | 66 | def yaml(obj) 67 | YAML.dump(obj) 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/support/fixtures.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Fixtures 5 | def self.included(const) 6 | const.extend(Fixtures) 7 | end 8 | 9 | DIR = ::File.expand_path('../fixtures', __dir__) 10 | 11 | class << self 12 | def [](key) 13 | fixtures[key] || raise("No fixture found for #{key}") 14 | end 15 | 16 | def fixtures 17 | @fixtures ||= Dir["#{DIR}/**/*.json"].map do |path| 18 | [path.sub("#{DIR}/", ''), ::File.read(path)] 19 | end.to_h 20 | end 21 | end 22 | 23 | def fixture(namespace, key) 24 | Fixtures["#{namespace}/#{key}"] 25 | end 26 | 27 | fixtures 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/support/gemfile.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'ripper' 4 | 5 | module Support 6 | module Gemfile 7 | module_function 8 | 9 | def gems 10 | code = ::File.read(::File.expand_path('../../Gemfile', __dir__)) 11 | sexp = Ripper.sexp(code) 12 | walk(*sexp) 13 | end 14 | 15 | def walk(key, *nodes) 16 | case key 17 | when :program 18 | nodes[0].map { |node| walk(*node) }.compact 19 | when :command 20 | walk(*nodes[1]) if nodes[0][1] == 'gem' 21 | when :args_add_block 22 | nodes[0].map { |node| walk(*node) } 23 | when :string_literal 24 | walk(*nodes[0]) 25 | when :string_content 26 | nodes[0][1] 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/support/helpers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Helpers 5 | def only(hash, *keys) 6 | hash.select { |key, _| keys.include?(key) }.to_h 7 | end 8 | 9 | def except(hash, *keys) 10 | hash.reject { |key, _| keys.include?(key) }.to_h 11 | end 12 | 13 | def compact(hash) 14 | hash.reject { |_, value| value.nil? } 15 | end 16 | 17 | def stringify(obj) 18 | case obj 19 | when Hash then obj.map { |key, obj| [key.to_s, stringify(obj)] }.to_h 20 | when Array then obj.map { |obj| stringify(obj) } 21 | else obj 22 | end 23 | end 24 | 25 | def symbolize(obj) 26 | case obj 27 | when Hash then obj.map { |key, obj| [key.to_sym, symbolize(obj)] }.to_h 28 | when Array then obj.map { |obj| symbolize(obj) } 29 | else obj 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/support/matchers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'support/matchers/aws' 4 | require 'support/matchers/have_deprecated' 5 | require 'support/matchers/have_env' 6 | require 'support/matchers/have_logged' 7 | require 'support/matchers/have_run' 8 | require 'support/matchers/have_written' 9 | require 'support/matchers/have_zipped' 10 | -------------------------------------------------------------------------------- /spec/support/matchers/have_deprecated.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'support/matchers/shared' 4 | 5 | module Support 6 | module Matchers 7 | class HaveDeprecated < Struct.new(:opt) 8 | include Shared 9 | 10 | def matches?(cmd) 11 | @cmd = cmd 12 | cmd.ctx.cmds.any? { |cmd| cmd =~ /Deprecated option.*#{opt} / } 13 | end 14 | 15 | def description 16 | "have deprecated #{opt.inspect}" 17 | end 18 | 19 | def failure_message 20 | "Expected the command\n\n #{opt}\n\nto be deprecated. Instead, we have run the commands:\n\n #{indent(cmd.ctx.cmds.join("\n"))}" 21 | end 22 | 23 | def failure_message_when_negated 24 | "Expected the command\n\n #{opt}\n\nto not be deprecated, but it is:\n\n #{indent(cmd.ctx.cmds.join("\n"))}" 25 | end 26 | end 27 | 28 | def have_deprecated(str) 29 | HaveDeprecated.new(str) 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /spec/support/matchers/have_env.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Matchers 5 | class HaveEnv < Struct.new(:env) 6 | include Shared 7 | 8 | def matches?(*) 9 | env.all? { |key, value| ENV[key.to_s] == value } 10 | end 11 | 12 | def description 13 | "run #{str.inspect}" 14 | end 15 | 16 | def failure_message 17 | "Expected ENV to include\n\n #{env.inspect}\n\nbut it does not." 18 | end 19 | 20 | def failure_message_when_negated 21 | "Expected ENV to not include\n\n #{env.inspect}\n\nbut it does." 22 | end 23 | end 24 | 25 | def have_env(str) 26 | HaveEnv.new(str) 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/support/matchers/have_logged.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec::Matchers.define :have_logged do |line| 4 | match do 5 | ctx.stderr.string.include?(line) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/support/matchers/have_run.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Matchers 5 | module RecordCmds 6 | def self.included(base) 7 | base.before(:context) { @expected_cmds = [] } 8 | end 9 | end 10 | 11 | class HaveRun < Struct.new(:cmds, :str) 12 | include Shared 13 | 14 | def matches?(cmd) 15 | cmds << str if cmds 16 | @cmd = cmd 17 | cmd.ctx.cmds.any? { |cmd, _opts| match?(cmd) } 18 | end 19 | 20 | def description 21 | "run #{str.inspect}" 22 | end 23 | 24 | def failure_message 25 | "Expected the command\n\n #{str}\n\nto have run, but it didn't. Instead, we have run the commands:\n\n #{indent(cmd.ctx.cmds.join("\n"))}" 26 | end 27 | 28 | def failure_message_when_negated 29 | "Expected the command\n\n #{str}\n\nto not have run, but it did:\n\n #{indent(cmd.ctx.cmds.join("\n"))}" 30 | end 31 | end 32 | 33 | # needs record: true on the context 34 | class HaveRunInOrder < Struct.new(:expected, :example) 35 | include Shared 36 | 37 | attr_reader :actual 38 | 39 | def matches?(cmd) 40 | @actual = cmd.ctx.cmds.map { |str| expected.detect { |cmd| match?(str, cmd) } }.compact.uniq 41 | expected == actual 42 | end 43 | 44 | def description 45 | 'have run commands in order' 46 | end 47 | 48 | def failure_message 49 | "Expected the commands\n\n#{indent(expected.join("\n"))}\n\nto have run in this order, but they have run as follows:\n\n#{indent(actual.join("\n"))}" 50 | end 51 | 52 | def indent(strs) 53 | strs.lines.map { |line| " #{line}" }.join 54 | end 55 | end 56 | 57 | def have_run(str) 58 | HaveRun.new(@expected_cmds, str) 59 | end 60 | 61 | def have_run_in_order 62 | # p example_group 63 | HaveRunInOrder.new(@expected_cmds) 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /spec/support/matchers/have_written.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec::Matchers.define :have_written do |path, str| 4 | match do 5 | path = File.expand_path(path) 6 | path = path.sub(File.expand_path('~').to_s, './home') 7 | str = str.chomp 8 | @file = File.read(path).chomp 9 | @file == str 10 | end 11 | 12 | failure_message do 13 | "Expected the file #{path} to contain:\n\n#{indent(str)}\n\nbut it contains:\n\n#{indent(@file)}" 14 | end 15 | 16 | def indent(str) 17 | str.lines.map { |line| ' ' * 4 + line }.join 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /spec/support/matchers/have_zipped.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec::Matchers.define :have_zipped do |path, files| 4 | match do 5 | expect(File.exist?(path)).to be true 6 | zipped = Zip::File.open(path) { |zip| zip.glob('*').map(&:name) } 7 | @files = zipped - ['./'] 8 | @files == files 9 | end 10 | 11 | failure_message do 12 | if File.exist?(path) 13 | "Expected the zip file #{path} to contain:\n\n#{indent(files)}\n\nbut it contains:\n\n#{indent(@files.join("\n"))}" 14 | else 15 | "Expected a zip file #{path} exist, but it doesn't" 16 | end 17 | end 18 | 19 | def indent(str) 20 | str.to_s.lines.map { |line| ' ' * 4 + line }.join 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/support/matchers/shared.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Matchers 5 | module Shared 6 | attr_reader :cmd 7 | 8 | def stringify(hash) 9 | hash.transform_keys { |key| key.to_s } 10 | end 11 | 12 | def match?(other, str = self.str) 13 | str.is_a?(Regexp) ? str.match(other) : str == other 14 | end 15 | 16 | def indent(str) 17 | return str if str.lines.size < 2 18 | 19 | str.lines[0] + str.lines[1..].map { |str| "#{' ' * 2}#{str}" }.join 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/support/now.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'time' 4 | 5 | module Support 6 | module Now 7 | def self.included(base) 8 | base.let(:now) { Time.now } 9 | base.before { allow(Time).to receive(:now).and_return(now) } 10 | end 11 | end 12 | end 13 | 14 | # https://stackoverflow.com/questions/44259104/rubyzip-undefined-method-to-binary-dos-time-for 15 | require 'zip' 16 | 17 | Zip::DOSTime.instance_eval do 18 | # ugh. 19 | def now = Zip::DOSTime.new 20 | end 21 | -------------------------------------------------------------------------------- /spec/support/require.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Support 4 | module Require 5 | def self.included(base) 6 | base.before do 7 | const = base.described_class 8 | next unless const.is_a?(Class) && const < Dpl::Provider 9 | 10 | paths = const.gem.map { |name, _, opts| opts[:require] || name }.flatten 11 | Array(paths).each { |path| Kernel.require(path) } 12 | end 13 | end 14 | end 15 | end 16 | --------------------------------------------------------------------------------