Skip to content

Commit 64e0143

Browse files
authored
Add ci and cd (#1)
* Go green * Add CI/CD for GitHub actions
1 parent 77e6f8b commit 64e0143

File tree

5 files changed

+156
-22
lines changed

5 files changed

+156
-22
lines changed

.github/workflows/cd.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CD
2+
3+
on:
4+
# This ensures we only run CD after the CI workflow has completed on the main branch.
5+
workflow_run:
6+
workflows: [CI]
7+
types: [completed]
8+
branches: [main]
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
# We only want to run this if CI completes *sucessfully*, see more here:
13+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
steps:
16+
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
17+
- name: Tag and Push Gem
18+
id: tag-and-push-gem
19+
# This action basically runs `bundle exec rake release` if there is not an existing tag in GitHub
20+
# for the current version of the gem, found in the `gemspec`.
21+
uses: discourse/publish-rubygems-action@2d713f2092b4f02da811f4b591a10b6b56f0780e
22+
env:
23+
# This is provided to GitHub Actions automatically – you do not need to add this secret.
24+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
25+
# These are used when the CD workflow pushes new tags to your repository.
26+
# Using tags helps people using your gem easily see changes between versions.
27+
# To get this value, try: `git config --get user.email`
28+
GIT_EMAIL: gpassero@gmail.com
29+
# To get this value, try: `git config --get user.name`
30+
GIT_NAME: Gary Passero
31+
# Get this from rubygems.org and add it as a secret to your repository.
32+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
33+
- name: Create GitHub Release
34+
# This creates a new release at https://github.com/rubyatscale/alexevanczuk-example-gem/releases,
35+
# which serves as an automatically generated changelog.
36+
run: gh release create v${{steps.tag-and-push-gem.outputs.gem_version}} --generate-notes
37+
# We only create a release if the previous step has published a new version.
38+
if: ${{ steps.tag-and-push-gem.outputs.new_version == 'true' }}
39+
env:
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
3+
# This runs every time a new commit is pushed to GitHub.
4+
on: [push]
5+
6+
jobs:
7+
rspec:
8+
runs-on: ubuntu-latest
9+
# We run our `rspec` tests on many versions of Ruby to ensure compatibility.
10+
strategy:
11+
matrix:
12+
ruby:
13+
- 2.7
14+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
15+
- '3.0'
16+
- 3.1
17+
- head
18+
env:
19+
BUNDLE_GEMFILE: Gemfile
20+
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
21+
steps:
22+
# This is an action from the public marketplace. We reference a specific commit as a security measure,
23+
# but there are many ways to reference an action:
24+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-versioned-actions
25+
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
26+
- name: Set up Ruby ${{ matrix.ruby }}
27+
uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
28+
with:
29+
# This caches the gems that bundle installs so subsequent runs can be faster.
30+
# It is what allows us to not run `gem install bundler` and `bundle install` in subsequent steps.
31+
bundler-cache: true
32+
ruby-version: ${{ matrix.ruby }}
33+
- name: Run tests
34+
run: bundle exec rspec
35+
rubocop:
36+
runs-on: ubuntu-latest
37+
name: Rubocop
38+
steps:
39+
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
40+
- name: Set up Ruby
41+
uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
42+
with:
43+
bundler-cache: true
44+
ruby-version: head
45+
- name: Run style checks
46+
run: bundle exec rubocop

Gemfile.lock

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
PATH
2+
remote: .
3+
specs:
4+
automatic_namespaces (0.1.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
ast (2.4.2)
10+
diff-lcs (1.5.0)
11+
json (2.6.2)
12+
parallel (1.22.1)
13+
parser (3.1.2.1)
14+
ast (~> 2.4.1)
15+
rainbow (3.1.1)
16+
rake (13.0.6)
17+
regexp_parser (2.6.0)
18+
rexml (3.2.5)
19+
rspec (3.12.0)
20+
rspec-core (~> 3.12.0)
21+
rspec-expectations (~> 3.12.0)
22+
rspec-mocks (~> 3.12.0)
23+
rspec-core (3.12.0)
24+
rspec-support (~> 3.12.0)
25+
rspec-expectations (3.12.0)
26+
diff-lcs (>= 1.2.0, < 2.0)
27+
rspec-support (~> 3.12.0)
28+
rspec-mocks (3.12.0)
29+
diff-lcs (>= 1.2.0, < 2.0)
30+
rspec-support (~> 3.12.0)
31+
rspec-support (3.12.0)
32+
rubocop (1.38.0)
33+
json (~> 2.3)
34+
parallel (~> 1.10)
35+
parser (>= 3.1.2.1)
36+
rainbow (>= 2.2.2, < 4.0)
37+
regexp_parser (>= 1.8, < 3.0)
38+
rexml (>= 3.2.5, < 4.0)
39+
rubocop-ast (>= 1.23.0, < 2.0)
40+
ruby-progressbar (~> 1.7)
41+
unicode-display_width (>= 1.4.0, < 3.0)
42+
rubocop-ast (1.23.0)
43+
parser (>= 3.1.1.0)
44+
ruby-progressbar (1.11.0)
45+
unicode-display_width (2.3.0)
46+
47+
PLATFORMS
48+
arm64-darwin-21
49+
x86_64-linux
50+
51+
DEPENDENCIES
52+
automatic_namespaces!
53+
rake (~> 13.0)
54+
rspec (~> 3.0)
55+
rubocop (~> 1.21)
56+
57+
BUNDLED WITH
58+
2.3.19

automatic_namespaces.gemspec

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,23 @@ Gem::Specification.new do |spec|
77
spec.version = AutomaticNamespaces::VERSION
88
spec.authors = ["Gary Passero"]
99
spec.email = ["gpassero@gmail.com"]
10-
11-
spec.summary = "TODO: Write a short summary, because RubyGems requires one."
12-
spec.description = "TODO: Write a longer description or delete this line."
13-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
10+
spec.summary = "Modify autoloading to assume all files within a directory belong in a namespace"
11+
spec.homepage = "https://github.com/gap777/automatic_namespaces"
1412
spec.license = "MIT"
1513
spec.required_ruby_version = ">= 2.6.0"
1614

17-
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18-
19-
spec.metadata["homepage_uri"] = spec.homepage
20-
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21-
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
15+
if spec.respond_to?(:metadata)
16+
spec.metadata["homepage_uri"] = spec.homepage
17+
spec.metadata["source_code_uri"] = "https://github.com/alexevanczuk/my_example_gem"
18+
spec.metadata["changelog_uri"] = "https://github.com/alexevanczuk/my_example_gem/releases"
19+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
20+
else
21+
raise "RubyGems 2.0 or newer is required to protect against " \
22+
"public gem pushes."
23+
end
2224

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

3428
# Uncomment to register a new dependency of your gem
3529
# spec.add_dependency "example-gem", "~> 1.0"

spec/automatic_namespaces_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
it "has a version number" do
55
expect(AutomaticNamespaces::VERSION).not_to be nil
66
end
7-
8-
it "does something useful" do
9-
expect(false).to eq(true)
10-
end
117
end

0 commit comments

Comments
 (0)