{"id":15658401,"url":"https://github.com/wata727/drunker","last_synced_at":"2025-05-04T08:14:43.535Z","repository":{"id":56844393,"uuid":"89773248","full_name":"wata727/drunker","owner":"wata727","description":"Distributed CLI runner on AWS CodeBuild","archived":false,"fork":false,"pushed_at":"2017-12-09T09:26:05.000Z","size":105,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T08:14:39.328Z","etag":null,"topics":["cli","codebuild","drunker","ruby","rubygems"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wata727.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-29T08:32:41.000Z","updated_at":"2019-12-21T13:41:44.000Z","dependencies_parsed_at":"2022-09-09T04:11:18.381Z","dependency_job_id":null,"html_url":"https://github.com/wata727/drunker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Fdrunker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Fdrunker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Fdrunker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Fdrunker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wata727","download_url":"https://codeload.github.com/wata727/drunker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252305251,"owners_count":21726623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","codebuild","drunker","ruby","rubygems"],"created_at":"2024-10-03T13:12:20.517Z","updated_at":"2025-05-04T08:14:43.511Z","avatar_url":"https://github.com/wata727.png","language":"Ruby","readme":"# Drunker\n[![Build Status](https://travis-ci.org/wata727/drunker.svg?branch=master)](https://travis-ci.org/wata727/drunker)\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE.txt)\n[![Gem Version](https://badge.fury.io/rb/drunker.svg)](https://badge.fury.io/rb/drunker)\n\nDistributed CLI runner on [AWS CodeBuild](https://aws.amazon.com/codebuild/). This is a wrapper for handling CodeBuild container more easily.\n\n## Installation\n\n    $ gem install drunker\n\n## Usage\n\nAll you need to use Drunker is the Docker image name of the container you want to use and the command you want to execute (Of course, AWS credentials is also necessary). For example, you can run [RSpec](https://github.com/rspec/rspec) on CodeBuild with the following command.\n\n```\n$ bundle install --path=vendor/bundle\n$ drunker run --env=BUNDLE_PATH:vendor/bundle/ruby/2.4.0 --timeout=5 ruby:2.4.1 bundle exec rspec\n```\n\nFirst, specify the Docker image name, and then the command you want to execute. After that, Drunker archives files under the current directory and uploads it to S3 and creates a CodeBuild project and the required IAM role.\n\nWhen preparation is completed, run builds, download artifacts from S3, and display it on your terminal. Resources created by Drunker are automatically deleted. Also, in this example, timeout and environment variables used inside containers are specified by options.\n\nYou can see execution result (e.g. STDOUT, STDERR and exit status) from output like the following.\n\n```\n-------------------------------------------------------------------------------------------\nBUILD_ID: drunker-executor-1494139943:10c9c785-bae0-4a2d-b5eb-927528943626\nRESULT: SUCCESS\nSTDOUT: .....................................................................................................................................\n\nFinished in 5.9 seconds (files took 0.17053 seconds to load)\n133 examples, 0 failures\n\nSTDERR:\nEXIT_STATUS: 0\n-------------------------------------------------------------------------------------------\n```\n\n### Parallel Build\n\nThe essence of Drunker is parallel build. For example, if you want to run RSpec in parallel, you can do it easily with the following command.\n\n```\n$ drunker run --concurrency=3 --file-pattern=\"spec/**/*_spec.rb\" --env=BUNDLE_PATH:vendor/bundle/ruby/2.4.0 --timeout=5 ruby:2.4.1 bundle exec rspec FILES\n```\n\n`FILES` included in the execution command has a special meaning. This is interpolated into the list of filenames according to the number of parallels. For example, in this case, it will be the following command (filename changes for each build):\n\n```\n$ bundle exec rspec spec/aggregator_spec.rb spec/artifact_spec.rb ...\n```\n\nThe target file is all files matching the glob pattern `**/*`. However, you can change this with `--file-pattern` option. You can see the execution result as the following:\n\n```\n-------------------------------------------------------------------------------------------\nBUILD_ID: drunker-executor-1494140968:59c0b89f-099e-482c-8995-659f8b6b8523\nRESULT: SUCCESS\nSTDOUT: ................\n\nFinished in 0.12019 seconds (files took 0.14562 seconds to load)\n16 examples, 0 failures\n\nSTDERR:\nEXIT_STATUS: 0\n-------------------------------------------------------------------------------------------\n\n\n-------------------------------------------------------------------------------------------\nBUILD_ID: drunker-executor-1494140968:f6cb0396-3005-44ca-8221-33b29cbbd309\nRESULT: SUCCESS\nSTDOUT: ..........................................................................\n\nFinished in 0.15774 seconds (files took 0.19026 seconds to load)\n74 examples, 0 failures\n\nSTDERR:\nEXIT_STATUS: 0\n-------------------------------------------------------------------------------------------\n\n\n-------------------------------------------------------------------------------------------\nBUILD_ID: drunker-executor-1494140968:620c471e-19e7-48da-95e7-42cd66728455\nRESULT: SUCCESS\nSTDOUT: ...........................................\n\nFinished in 5.56 seconds (files took 0.14991 seconds to load)\n43 examples, 0 failures\n\nSTDERR:\nEXIT_STATUS: 0\n-------------------------------------------------------------------------------------------\n```\n\nWhat is surprising is that do not require your local machine specs at all even if you increase the number of parallels. You can increase the number of parallels within the bounds of common sense.\n\n### Limitation\nThe number of parallelism of CodeBuild is determined by default. If the limit is reached, Drunker queues remaining builders.\n\n```\nINFO: Maximum number of concurrent running builds has been reached. it will retry later...\nINFO: Waiting builder: 1/25, queues: 4\n...\n```\n\nFor details about limitation, please see [here](http://docs.aws.amazon.com/codebuild/latest/userguide/limits.html).\n\n### EC2 Container Registry\n\nDo you want to use private images? You can also specify the image of [EC2 Container Registry](https://aws.amazon.com/ecr/). Following example:\n\n```\n$ drunker run account-ID.dkr.ecr.us-east-1.amazonaws.com/your-Amazon-ECR-repo-name:latest ruby task.rb\n```\n\nFor details, please see [Amazon ECR Sample for AWS CodeBuild](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html).\n\n## Available Options\n\nPlease show `drunker help run`\n\n```\nUsage:\n  drunker run [IMAGE] [COMMAND]\n\nOptions:\n  [--config=CONFIG]              # Location of config file\n                                 # Default: .drunker.yml\n  [--concurrency=N]              # Build concurrency\n                                 # Default: 1\n  [--compute-type=COMPUTE_TYPE]  # Container compute type\n                                 # Default: small\n                                 # Possible values: small, medium, large\n  [--timeout=N]                  # Build timeout in minutes, should be between 5 and 480\n                                 # Default: 60\n  [--env=key:value]              # Environment variables in containers\n  [--buildspec=BUILDSPEC]        # Location of custom buildspec\n  [--file-pattern=FILE_PATTERN]  # FILES target file pattern, can use glob to specify, but files beginning with a dot are ignored.\n                                 # Default: **/*\n  [--aggregator=AGGREGATOR]      # Aggregator name. If you want to use custom aggregator, please install that beforehand.\n  [--loglevel=LOGLEVEL]          # Output log level\n                                 # Default: info\n                                 # Possible values: debug, info, warn, error, fatal\n  [--debug], [--no-debug]        # Enable debug mode. This mode does not delete the AWS resources created by Drunker\n  [--access-key=ACCESS_KEY]      # AWS access key token used by Drunker\n  [--secret-key=SECRET_KEY]      # AWS secret key token used by Drunker\n  [--region=REGION]              # AWS region in which resources is created by Drunker\n  [--profile-name=PROFILE_NAME]  # AWS shared credentials profile name used by Drunker\n\nRun a command on CodeBuild\n```\n\n## Configuration\n\nBy default, it loads `.drunker.yml`. In the configuration file, many options can be written in advance. Following example:\n\n```yaml\nconcurrency: 10\ncompute_type: medium\ntimeout: 5\nfile_pattern: spec/**/*_spec.rb\nenvironment_variables:\n  RAILS_ENV: test\n  SECRET_KEY_BASE: super secret\naws_credentials:\n  access_key: AWS_ACCESS_KEY_ID\n  secret_key: AWS_SECRET_ACCESS_KEY\n  region: us-east-1\n```\n\nIf you want to create a configuration file with a different name, specify the file name with --config option.\n\n```\n$ drunker run --config=.custom_drunker.yml ruby:2.4.1 bundle exec rspec\n```\n\n### Credentials\n\nDrunker supports various credential providers. It is used with the following priority:\n\n- Specified shared credentials\n- Static credentials\n- Environment credentials\n- Default shared credentials\n\n#### Static Credentials\n\nIf you have access key and secret key, you can specify these credentials.\n\n```\n$ drunker run --access-key=AWS_ACCESS_KEY_ID --secret-key=AWS_SECRET_ACCESS_KEY --region=us-east-1 owner_name/image_name ruby task.rb\n```\n\n```yaml\naws_credentials:\n  access_key: AWS_ACCESS_KEY_ID\n  secret_key: AWS_SECRET_ACCESS_KEY\n  region: us-east-1\n```\n\n#### Shared Credentials\n\nIf you have [shared credentials](https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/), you can specify credentials profile name. However Drunker supports only `~/.aws/credentials` as shared credentials location.\n\n```\n$ drunker run --profile-name=PROFILE_NAME --region=us-east-1 owner_name/image_name ruby task.rb\n```\n\n```yaml\naws_credentials:\n  profile_name: PROFILE_NAME\n  region: us-east-1\n```\n\n## Customize Build Specification\n\nDo you want to customize the build specification more? You can change the `buildspec.yml` that is used by Drunker. The default `buildspec.yml` is [here](https://github.com/wata727/drunker/tree/master/lib/drunker/executor/buildspec.yml.erb). For example, if you want to run `bundle install` in the install phase, create the `custom_buildspec.yml` like the following.\n\n```yaml\nversion: 0.1\nphases:\n  install:\n    commands:\n      - bundle install\n  build:\n    commands:\n      - \u003c%= commands.join(\" \") %\u003e 1\u003e \u003c%= stdout %\u003e 2\u003e \u003c%= stderr %\u003e; echo $? \u003e \u003c%= exit_status %\u003e\nartifacts:\n  files:\n    - \u003c%= stdout %\u003e\n    - \u003c%= stderr %\u003e\n    - \u003c%= exit_status %\u003e\n```\n\nActual commands and output files are interpolated by ERB. Please see [here](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) for how to write `buildspec.yml`. After that, specify the file path with the `--buildspec` option.\n\n```\n$ drunker run --buildspec=custom_buildspec.yml owner_name/image_name ruby task.rb\n```\n\nAlso, you can specify it in the configuration file.\n\n```yaml\nbuildspec: custom_buildspec.yml\n```\n\nIn configuration file, you can also be described inline style.\n\n```yaml\nbuildspec:\n  version: 0.1\n  phases:\n    install:\n      commands:\n        - bundle install\n    build:\n      commands:\n        - \u003c%= commands.join(\" \") %\u003e 1\u003e \u003c%= stdout %\u003e 2\u003e \u003c%= stderr %\u003e; echo $? \u003e \u003c%= exit_status %\u003e\n  artifacts:\n    files:\n      - \u003c%= stdout %\u003e\n      - \u003c%= stderr %\u003e\n      - \u003c%= exit_status %\u003e\n```\n\n## Customize Output\n\nDo you want to customize the output format? You can customize output format, exit code by creating Gem called aggregator. The specifications that the aggregator must satisfy are the following five.\n\n- The name of Gem must be `drunker-aggregator-#{name}`.\n- Create `lib/drunker-aggregator-#{name}.rb`, and require `Drunker::Aggregator::#{name}` class\n- `Drunker::Aggregator::#{name}` must inherit `Drunker::Aggregator::Base`\n- Implement `run` and `exit_status` methods to receive array of `Drunker::Artifact::Layer`\n- Return a number in `exit_status` method\n\n`Drunker::Artifact::Layer` has outputs and build ID for each build. Please see the [implementation](https://github.com/wata727/drunker/blob/master/lib/drunker/artifact/layer.rb) for details.\n\nFor example, [this aggregator](https://github.com/wata727/drunker-aggregator-phpmd) can aggregate for PHPMD XML format report.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wata727/drunker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwata727%2Fdrunker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwata727%2Fdrunker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwata727%2Fdrunker/lists"}