Skip to content

Commit

Permalink
Add ci and cd (#1)
Browse files Browse the repository at this point in the history
* Go green

* Add CI/CD for GitHub actions
  • Loading branch information
gap777 authored Nov 1, 2022
1 parent 77e6f8b commit 64e0143
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 22 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CD

on:
# This ensures we only run CD after the CI workflow has completed on the main branch.
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
# We only want to run this if CI completes *sucessfully*, see more here:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
- name: Tag and Push Gem
id: tag-and-push-gem
# This action basically runs `bundle exec rake release` if there is not an existing tag in GitHub
# for the current version of the gem, found in the `gemspec`.
uses: discourse/publish-rubygems-action@2d713f2092b4f02da811f4b591a10b6b56f0780e
env:
# This is provided to GitHub Actions automatically – you do not need to add this secret.
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# These are used when the CD workflow pushes new tags to your repository.
# Using tags helps people using your gem easily see changes between versions.
# To get this value, try: `git config --get user.email`
GIT_EMAIL: [email protected]
# To get this value, try: `git config --get user.name`
GIT_NAME: Gary Passero
# Get this from rubygems.org and add it as a secret to your repository.
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
- name: Create GitHub Release
# This creates a new release at https://github.com/rubyatscale/alexevanczuk-example-gem/releases,
# which serves as an automatically generated changelog.
run: gh release create v${{steps.tag-and-push-gem.outputs.gem_version}} --generate-notes
# We only create a release if the previous step has published a new version.
if: ${{ steps.tag-and-push-gem.outputs.new_version == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

# This runs every time a new commit is pushed to GitHub.
on: [push]

jobs:
rspec:
runs-on: ubuntu-latest
# We run our `rspec` tests on many versions of Ruby to ensure compatibility.
strategy:
matrix:
ruby:
- 2.7
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
- '3.0'
- 3.1
- head
env:
BUNDLE_GEMFILE: Gemfile
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
steps:
# This is an action from the public marketplace. We reference a specific commit as a security measure,
# but there are many ways to reference an action:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-versioned-actions
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
with:
# This caches the gems that bundle installs so subsequent runs can be faster.
# It is what allows us to not run `gem install bundler` and `bundle install` in subsequent steps.
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- name: Run tests
run: bundle exec rspec
rubocop:
runs-on: ubuntu-latest
name: Rubocop
steps:
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
- name: Set up Ruby
uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
with:
bundler-cache: true
ruby-version: head
- name: Run style checks
run: bundle exec rubocop
58 changes: 58 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
PATH
remote: .
specs:
automatic_namespaces (0.1.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
diff-lcs (1.5.0)
json (2.6.2)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.0)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.38.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
unicode-display_width (2.3.0)

PLATFORMS
arm64-darwin-21
x86_64-linux

DEPENDENCIES
automatic_namespaces!
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 1.21)

BUNDLED WITH
2.3.19
30 changes: 12 additions & 18 deletions automatic_namespaces.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ Gem::Specification.new do |spec|
spec.version = AutomaticNamespaces::VERSION
spec.authors = ["Gary Passero"]
spec.email = ["[email protected]"]

spec.summary = "TODO: Write a short summary, because RubyGems requires one."
spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.summary = "Modify autoloading to assume all files within a directory belong in a namespace"
spec.homepage = "https://github.com/gap777/automatic_namespaces"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"

spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
if spec.respond_to?(:metadata)
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/alexevanczuk/my_example_gem"
spec.metadata["changelog_uri"] = "https://github.com/alexevanczuk/my_example_gem/releases"
spec.metadata["allowed_push_host"] = "https://rubygems.org"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.files = Dir["README.md", "lib/**/*"]

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
Expand Down
4 changes: 0 additions & 4 deletions spec/automatic_namespaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
it "has a version number" do
expect(AutomaticNamespaces::VERSION).not_to be nil
end

it "does something useful" do
expect(false).to eq(true)
end
end

0 comments on commit 64e0143

Please sign in to comment.