founders_template 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e33d787c6736db9ea253774787e9f7b3705b9e06afe93e1ca01411cdcad8e419
4
+ data.tar.gz: 17b6c122ec9e2f974b53bc3726bb58f758c7c78d9148855d782535b8dfa1456e
5
+ SHA512:
6
+ metadata.gz: 6ee77f90541b14c3be44429343302df959d3ba6bd713c95678a3a68564c99cc1bd7d819d2c11d03fbd6caeb3975f4e8e9f2a4640c830462276df6e6c891e2a9d
7
+ data.tar.gz: 918607bfd74e654da98d9861705a2b6f4195a9e6bb2938b9833f11619ba67d48a2ce8e5b4410a5163d50f260a5cd8c30f09222802f969be428c0ac7e36bfaa8c
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [ '2.5', '2.6', '2.7' ]
11
+ rails: [ 5, 6 ]
12
+ name: founders_template ruby:${{matrix.ruby}} rails:${{matrix.rails}}
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ - run: |
20
+ gem install bundler
21
+ bundle install --jobs 4 --retry 3 --gemfile=Gemfile-rails${{matrix.rails}}
22
+ bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ vendor/
13
+ .rubocop-*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/trobrock/style-guides/master/ruby-style.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'bin/*'
7
+ - db/schema.rb
data/Gemfile-rails5 ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in founders_template.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile-rails6 ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in founders_template.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ founders_template (0.1.0)
5
+ thor (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ rake (12.3.3)
12
+ rspec (3.9.0)
13
+ rspec-core (~> 3.9.0)
14
+ rspec-expectations (~> 3.9.0)
15
+ rspec-mocks (~> 3.9.0)
16
+ rspec-core (3.9.1)
17
+ rspec-support (~> 3.9.1)
18
+ rspec-expectations (3.9.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.9.0)
21
+ rspec-mocks (3.9.1)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.9.0)
24
+ rspec-support (3.9.2)
25
+ thor (1.0.1)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ founders_template!
32
+ rake (~> 12.0)
33
+ rspec (~> 3.0)
34
+
35
+ BUNDLED WITH
36
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Trae Robrock
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # FoundersTemplate
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/founders_template`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'founders_template'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install founders_template
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After 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.
30
+
31
+ To 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/founders_template.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bash/.gitkeep ADDED
File without changes
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+
3
+ TARGET="$1"
4
+
5
+ if [[ "$TARGET" -eq "app" ]]; then
6
+ HAS_DOCKER_IMAGE="$(docker image ls --filter "reference=$APP_REPOSITORY_URI:latest" --format "{{.ID}}" | wc -l)"
7
+ CACHE_IMAGE="$(if [ $HAS_DOCKER_IMAGE -eq "1" ]; then echo "--cache-from $APP_REPOSITORY_URI:latest" ; fi)"
8
+ else
9
+ CACHE_IMAGE="--cache-from app:$GIT_COMMIT_SHA"
10
+ fi
11
+
12
+ echo "Building the $TARGET Docker image..."
13
+ exec docker build \
14
+ $CACHE_IMAGE \
15
+ --build-arg RAILS_ENV=$RAILS_ENV \
16
+ --build-arg DATABASE_URL=$DATABASE_URL \
17
+ --build-arg REDIS_URL=$REDIS_URL \
18
+ --build-arg SECRET_KEY_BASE=$RAILS_SECRET_KEY \
19
+ --build-arg RAILS_MASTER_KEY=$RAILS_MASTER_KEY \
20
+ --build-arg AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \
21
+ --build-arg AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \
22
+ -t $TARGET:$GIT_COMMIT_SHA \
23
+ --target $TARGET .
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cat <<-EOF
4
+ export \
5
+ GIT_COMMIT_SHA=$CODEBUILD_RESOLVED_SOURCE_VERSION \
6
+ GIT_COMMITTED_AT=$(echo $CODEBUILD_START_TIME | sed 's/.\{3\}$//') \
7
+ IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)-$(echo $CODEBUILD_BUILD_ID | sed 's/:/-/g')
8
+ EOF
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ aws ecr get-login --region $AWS_REGION --no-include-email
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo $CODEBUILD_SOURCE_VERSION
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo $CODEBUILD_RESOLVED_SOURCE_VERSION
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo $CODEBUILD_START_TIME | sed 's/.\{3\}$//'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "$(ft ci get_git_commit_sha | cut -c 1-7)-$(echo $CODEBUILD_BUILD_ID | sed 's/:/-/g')"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ CUSTOM_INSTALL_FILE="ci/install.sh"
6
+
7
+ ft ci print_versions
8
+
9
+ if [ -f "$CUSTOM_INSTALL_FILE" ] ; then
10
+ echo "Running custom install"
11
+ exec bash "$CUSTOM_INSTALL_FILE"
12
+ fi
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ CUSTOM_INSTALL_FILE="ci/post_install.sh"
6
+
7
+ ft ci push_images
8
+ ft ci write_artifacts
9
+
10
+ if [ -f "$CUSTOM_INSTALL_FILE" ] ; then
11
+ echo "Running custom install"
12
+ exec bash "$CUSTOM_INSTALL_FILE"
13
+ fi
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Printing version info of docker and compose"
4
+ docker version
5
+ docker-compose version
@@ -0,0 +1,2 @@
1
+ echo "Pulling latest docker image"
2
+ docker pull $APP_REPOSITORY_URI:latest || true
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Pushing the Docker images"
4
+ docker push $APP_REPOSITORY_URI:$IMAGE_TAG
5
+ docker push $APP_REPOSITORY_URI:latest
6
+ docker push $WEB_REPOSITORY_URI:$IMAGE_TAG
7
+ docker push $WEB_REPOSITORY_URI:latest
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ extra_environment=""
6
+ for e in $@
7
+ do
8
+ extra_environment="$extra_environment -e $e"
9
+ done
10
+
11
+ echo Running tests...
12
+ sed -i "s;%IMAGE;app:$GIT_COMMIT_SHA;" docker-compose.ci.yml
13
+ exec docker-compose -f docker-compose.ci.yml \
14
+ run --entrypoint "/bin/sh -c" \
15
+ -e GIT_COMMIT_SHA \
16
+ -e GIT_COMMITTED_AT \
17
+ $extra_environment \
18
+ app "exec sh ./ci/run_tests.sh"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Tagging Docker images"
4
+ docker tag app:$GIT_COMMIT_SHA $APP_REPOSITORY_URI:$IMAGE_TAG
5
+ docker tag app:$GIT_COMMIT_SHA $APP_REPOSITORY_URI:latest
6
+ docker tag web:$GIT_COMMIT_SHA $WEB_REPOSITORY_URI:$IMAGE_TAG
7
+ docker tag web:$GIT_COMMIT_SHA $WEB_REPOSITORY_URI:latest
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo Writing image definitions file...
4
+ printf '[{"name":"app","imageUri":"%s"}, {"name":"web","imageUri":"%s"}]' $APP_REPOSITORY_URI:$IMAGE_TAG $WEB_REPOSITORY_URI:$IMAGE_TAG > web_imagedefinitions.json
5
+ printf '[{"name":"worker","imageUri":"%s"}]' $APP_REPOSITORY_URI:$IMAGE_TAG > worker_imagedefinitions.json
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "founders_template"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/ft ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'founders_template'
5
+ require 'founders_template/cli'
6
+
7
+ FoundersTemplate::CLI.start(ARGV)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/founders_template/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'founders_template'
7
+ spec.version = FoundersTemplate::VERSION
8
+ spec.authors = ['Trae Robrock']
9
+ spec.email = ['trobrock@gmail.com']
10
+
11
+ spec.summary = "The command line tool used to manage the Founder's Template"
12
+ spec.description = "The command line tool used to manage the Founder's Template"
13
+ spec.homepage = 'https://github.com/trobrock/founders_template'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/trobrock/founders_template.git'
19
+ # spec.metadata['changelog_uri'] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'thor', '~> 1.0'
31
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'shellwords'
4
+ require 'thor'
5
+
6
+ SCRIPT_PATH = File.expand_path(File.join(__dir__, '..', '..', 'bash')).freeze
7
+
8
+ module FoundersTemplate
9
+ class CLI < Thor
10
+ desc 'ci SCRIPT_NAME', 'exec the ci script SCRIPT_NAME'
11
+ def ci(script_name, *args)
12
+ script_name = Shellwords.escape(script_name)
13
+ file_path = File.join(SCRIPT_PATH, 'ci', "#{script_name}.sh")
14
+
15
+ exec '/usr/bin/env', 'bash', file_path, *args
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module FoundersTemplate
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "founders_template/version"
2
+
3
+ module FoundersTemplate
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: founders_template
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Trae Robrock
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: The command line tool used to manage the Founder's Template
28
+ email:
29
+ - trobrock@gmail.com
30
+ executables:
31
+ - ft
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".github/workflows/ci.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - Gemfile-rails5
40
+ - Gemfile-rails6
41
+ - Gemfile-rails6.lock
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - bash/.gitkeep
46
+ - bash/ci/build_image.sh
47
+ - bash/ci/export_build_variables.sh
48
+ - bash/ci/export_ecr_login.sh
49
+ - bash/ci/get_git_branch.sh
50
+ - bash/ci/get_git_commit_sha.sh
51
+ - bash/ci/get_git_committed_at.sh
52
+ - bash/ci/get_image_tag.sh
53
+ - bash/ci/install.sh
54
+ - bash/ci/post_build.sh
55
+ - bash/ci/print_versions.sh
56
+ - bash/ci/pull_latest_image.sh
57
+ - bash/ci/push_images.sh
58
+ - bash/ci/run_tests.sh
59
+ - bash/ci/tag_images.sh
60
+ - bash/ci/write_artifacts.sh
61
+ - bin/console
62
+ - bin/setup
63
+ - exe/ft
64
+ - founders_template.gemspec
65
+ - lib/founders_template.rb
66
+ - lib/founders_template/cli.rb
67
+ - lib/founders_template/version.rb
68
+ homepage: https://github.com/trobrock/founders_template
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/trobrock/founders_template
73
+ source_code_uri: https://github.com/trobrock/founders_template.git
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.3.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.1.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: The command line tool used to manage the Founder's Template
93
+ test_files: []