Skip to content

Commit d81c9fe

Browse files
authored
add test coverage (#2)
* add test coverage * rename Main * bump version to test tagging and publishing * run `bundle install`
1 parent 84aaf01 commit d81c9fe

9 files changed

Lines changed: 71 additions & 59 deletions

File tree

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- uses: ruby/setup-ruby@v1.152.0
17+
with:
18+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
19+
20+
- run: bin/rspec
21+
22+
- uses: codecov/codecov-action@v3
23+
with:
24+
token: ${{ secrets.CODECOV_TOKEN }}
25+
26+
tag:
27+
needs: test
28+
if: github.ref == 'refs/heads/main'
29+
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
packages: write
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 2
39+
40+
- uses: salsify/action-detect-and-tag-new-version@v2
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@ name: Push Ruby Gem
22

33
on:
44
push:
5-
tags: [*]
5+
tags: ["*"]
66

77
jobs:
8-
build:
8+
push:
99
runs-on: ubuntu-latest
10-
permissions:
11-
contents: read
12-
packages: write
1310

1411
steps:
1512
- uses: actions/checkout@v3
1613
with:
1714
fetch-depth: 2
1815

19-
- name: Setup Ruby
20-
uses: ruby/setup-ruby@v1.152.0
16+
- uses: ruby/setup-ruby@v1.152.0
2117
with:
2218
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
2319

24-
- name: Publish to RubyGems
25-
run: |
20+
- run: |
2621
mkdir -p $HOME/.gem
2722
touch $HOME/.gem/credentials
2823
chmod 0600 $HOME/.gem/credentials

.github/workflows/specs.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/tag.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.gem
2+
coverage

Gemfile.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
PATH
22
remote: .
33
specs:
4-
typeid (0.1.1)
4+
typeid (0.1.2)
55
uuid7 (~> 0.2.0)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
1010
coderay (1.1.3)
1111
diff-lcs (1.5.0)
12+
docile (1.4.0)
1213
method_source (1.0.0)
1314
pry (0.14.2)
1415
coderay (~> 1.1)
1516
method_source (~> 1.0)
17+
rexml (3.2.5)
1618
rspec (3.12.0)
1719
rspec-core (~> 3.12.0)
1820
rspec-expectations (~> 3.12.0)
@@ -26,6 +28,15 @@ GEM
2628
diff-lcs (>= 1.2.0, < 2.0)
2729
rspec-support (~> 3.12.0)
2830
rspec-support (3.12.1)
31+
simplecov (0.22.0)
32+
docile (~> 1.1)
33+
simplecov-html (~> 0.11)
34+
simplecov_json_formatter (~> 0.1)
35+
simplecov-cobertura (2.1.0)
36+
rexml
37+
simplecov (~> 0.19)
38+
simplecov-html (0.12.3)
39+
simplecov_json_formatter (0.1.4)
2940
uuid7 (0.2.0)
3041
zeitwerk (~> 2.4)
3142
zeitwerk (2.6.8)
@@ -37,6 +48,8 @@ PLATFORMS
3748
DEPENDENCIES
3849
pry (~> 0.14.2)
3950
rspec (~> 3.12)
51+
simplecov (~> 0.22.0)
52+
simplecov-cobertura (~> 2.1)
4053
typeid!
4154

4255
BUNDLED WITH

lib/typeid/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class TypeID < String
2-
VERSION = "0.1.1".freeze
2+
VERSION = "0.1.2".freeze
33
end

spec/spec_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
require "simplecov"
2+
3+
SimpleCov.start do
4+
if ENV["CI"]
5+
require "simplecov-cobertura"
6+
formatter SimpleCov::Formatter::CoberturaFormatter
7+
end
8+
end
9+
110
# This file was generated by the `rspec --init` command. Conventionally, all
211
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
312
# The generated `.rspec` file contains `--require spec_helper` which will cause

typeid.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
1414
gem.add_runtime_dependency "uuid7", "~> 0.2.0"
1515
gem.add_development_dependency "rspec", "~> 3.12"
1616
gem.add_development_dependency "pry", "~> 0.14.2"
17+
gem.add_development_dependency "simplecov", "~> 0.22.0"
18+
gem.add_development_dependency "simplecov-cobertura", "~> 2.1"
1719
end

0 commit comments

Comments
 (0)