Skip to content

Commit d61d324

Browse files
authored
ci: add Github Actions (#4)
1 parent 995b5b5 commit d61d324

File tree

12 files changed

+203
-34
lines changed

12 files changed

+203
-34
lines changed

.bundle/config

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Appraisal install
2+
inputs:
3+
appraisal:
4+
description: "Appraisal version to install"
5+
required: true
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Copy lockfile
11+
shell: bash
12+
run: bundle exec appraisal ${{ inputs.appraisal }} "cp \$BUNDLE_GEMFILE.lock current_appraisal.gemfile.lock"
13+
- name: Appraisal package cache
14+
uses: actions/cache@v4
15+
with:
16+
key: v6-gem-cache-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('current_appraisal.gemfile.lock') }}
17+
path: vendor/bundle
18+
restore-keys: |
19+
v6-gem-cache-${{ runner.os }}-${{ github.ref }}-
20+
v6-gem-cache-${{ runner.os }}-
21+
- name: Install appraisal dependencies
22+
shell: bash
23+
run: bundle exec appraisal ${{ inputs.appraisal }} bundle install --jobs=1 --retry=3 --path=../vendor/bundle

.github/workflows/ci.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Main
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
ruby-lint:
10+
runs-on: ubuntu-latest
11+
env:
12+
BUNDLE_APP_CONFIG: .bundle
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: '3.2'
18+
bundler-cache: true
19+
- run: bundle exec rubocop
20+
ruby-test:
21+
runs-on: ubuntu-latest
22+
env:
23+
BUNDLE_APP_CONFIG: .bundle
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
appraisal: [ 'graphql-1.10', 'graphql-1.11', 'graphql-1.12', 'graphql-1.13', 'graphql-2.0' ]
28+
ruby: [ '3.0', '3.1', '3.2' ]
29+
exclude:
30+
- appraisal: 'graphql-1.10'
31+
ruby: '3.2'
32+
- appraisal: 'graphql-1.11'
33+
ruby: '3.2'
34+
- appraisal: 'graphql-1.12'
35+
ruby: '3.2'
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: ${{ matrix.ruby }}
41+
bundler-cache: true
42+
- name: Run appraisal install
43+
uses: ./.github/actions/appraisal-install
44+
with:
45+
appraisal: ${{ matrix.appraisal }}
46+
- run: bundle config list
47+
- run: bundle exec appraisal ${{ matrix.appraisal }} bundle config list
48+
- run: bundle exec appraisal ${{ matrix.appraisal }} rake
49+
50+
integration-tests:
51+
runs-on: ubuntu-latest
52+
env:
53+
BUNDLE_APP_CONFIG: .bundle
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
appraisal: [ 'graphql-1.10', 'graphql-1.11', 'graphql-1.12', 'graphql-1.13', 'graphql-2.0' ]
58+
ruby: [ '3.0', '3.1', '3.2' ]
59+
exclude:
60+
- appraisal: 'graphql-1.10'
61+
ruby: '3.2'
62+
- appraisal: 'graphql-1.11'
63+
ruby: '3.2'
64+
- appraisal: 'graphql-1.12'
65+
ruby: '3.2'
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: ruby/setup-ruby@v1
69+
with:
70+
ruby-version: ${{ matrix.ruby }}
71+
bundler-cache: true
72+
- name: Run appraisal install
73+
uses: ./.github/actions/appraisal-install
74+
with:
75+
appraisal: ${{ matrix.appraisal }}
76+
- name: Run install
77+
uses: borales/actions-yarn@v4
78+
with:
79+
cmd: install
80+
- run: bundle exec appraisal ${{ matrix.appraisal }} yarn test
81+
- run: yarn lint
82+
83+
release:
84+
runs-on: ubuntu-latest
85+
needs: [ ruby-lint, ruby-test, integration-tests ]
86+
if: github.ref == 'refs/heads/main'
87+
env:
88+
BUNDLE_APP_CONFIG: .bundle
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: ruby/setup-ruby@v1
92+
with:
93+
ruby-version: '3.2'
94+
bundler-cache: true
95+
- name: Run install
96+
uses: borales/actions-yarn@v4
97+
with:
98+
cmd: install
99+
- run: npx semantic-release

.github/workflows/semantic.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,41 @@ on:
66
- opened
77
- edited
88
- synchronize
9+
- reopened
10+
11+
permissions:
12+
pull-requests: write
913

1014
jobs:
1115
main:
1216
name: Validate PR title
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: amannn/action-semantic-pull-request@v5
20+
id: lint_pr_title
1621
env:
1722
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- uses: marocchino/sticky-pull-request-comment@v2
25+
# When the previous steps fails, the workflow would stop. By adding this
26+
# condition you can continue the execution with the populated error message.
27+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
28+
with:
29+
header: pr-title-lint-error
30+
message: |
31+
Hey there and thank you for opening this pull request! 👋🏼
32+
33+
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
34+
35+
Details:
36+
37+
```
38+
${{ steps.lint_pr_title.outputs.error_message }}
39+
```
40+
41+
# Delete a previous comment when the issue has been resolved
42+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
43+
uses: marocchino/sticky-pull-request-comment@v2
44+
with:
45+
header: pr-title-lint-error
46+
delete: true

.rubocop.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ require: rubocop-rspec
33
AllCops:
44
TargetRubyVersion: 2.3
55
DisplayCopNames: true
6+
NewCops: disable
67
Exclude:
78
- 'node_modules/**/*'
89
- 'gemfiles/**/*'
910
- 'vendor/**/*'
1011

12+
Gemspec/DevelopmentDependencies:
13+
Enabled: false
1114
#
1215
# We prefer trailing commas so that the git diff is reduced when adding elements
1316
#
@@ -20,8 +23,6 @@ Style/TrailingCommaInArrayLiteral:
2023
Style/TrailingCommaInHashLiteral:
2124
Enabled: true
2225
EnforcedStyleForMultiline: consistent_comma
23-
Style/BracesAroundHashParameters:
24-
EnforcedStyle: context_dependent
2526
Style/ConditionalAssignment:
2627
EnforcedStyle: assign_inside_condition
2728
IncludeTernaryExpressions: false
@@ -37,7 +38,12 @@ Style/NegatedIf:
3738
Enabled: false
3839
Style/Documentation:
3940
Enabled: false
40-
41+
Style/HashAsLastArrayItem:
42+
Enabled: false
43+
Naming/VariableNumber:
44+
Enabled: false
45+
Lint/ConstantDefinitionInBlock:
46+
Enabled: false
4147
Metrics/AbcSize:
4248
Enabled: false
4349
Metrics/BlockLength:
@@ -49,11 +55,10 @@ Metrics/ModuleLength:
4955
Metrics/ParameterLists:
5056
Max: 5
5157
CountKeywordArgs: false
52-
Metrics/LineLength:
58+
Layout/LineLength:
5359
Max: 120
5460
Exclude:
5561
- lib/apollo-federation/tracing/proto/apollo_pb.rb
56-
5762
Naming/FileName:
5863
Exclude:
5964
- 'lib/apollo-federation.rb'
@@ -63,10 +68,21 @@ RSpec/ExampleLength:
6368
Enabled: false
6469
RSpec/NestedGroups:
6570
Enabled: false
66-
RSpec/FilePath:
71+
RSpec/SpecFilePathFormat:
6772
CustomTransform:
6873
ApolloFederation: apollo-federation
69-
74+
RSpec/RepeatedExampleGroupDescription:
75+
Enabled: false
76+
RSpec/LeakyConstantDeclaration:
77+
Enabled: false
78+
RSpec/MultipleMemoizedHelpers:
79+
Enabled: false
80+
RSpec/IndexedLet:
81+
Enabled: false
82+
RSpec/EmptyLineAfterExample:
83+
Enabled: false
84+
RSpec/MatchArray:
85+
Enabled: false
7086
# Disabled so we can support Ruby 2.2
7187
# Rubocop only supports >= 2.3
7288
Gemspec/RequiredRubyVersion:

Gemfile.lock

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,14 @@ GEM
4242
coderay (1.1.3)
4343
concurrent-ruby (1.2.2)
4444
crass (1.0.6)
45-
debase (0.2.5.beta2)
46-
debase-ruby_core_source (>= 0.10.12)
47-
debase-ruby_core_source (3.2.0)
4845
diff-lcs (1.5.0)
4946
erubi (1.12.0)
5047
google-protobuf (3.22.2)
5148
graphql (2.0.19)
5249
i18n (1.12.0)
5350
concurrent-ruby (~> 1.0)
54-
jaro_winkler (1.5.4)
51+
json (2.8.1)
52+
language_server-protocol (3.17.0.3)
5553
loofah (2.19.1)
5654
crass (~> 1.0.2)
5755
nokogiri (>= 1.5.9)
@@ -67,16 +65,17 @@ GEM
6765
racc (~> 1.4)
6866
nokogiri (1.14.2-x86_64-linux)
6967
racc (~> 1.4)
70-
parallel (1.22.1)
71-
parser (3.2.1.1)
68+
parallel (1.26.3)
69+
parser (3.3.6.0)
7270
ast (~> 2.4.1)
71+
racc
7372
pry (0.14.2)
7473
coderay (~> 1.1)
7574
method_source (~> 1.0)
7675
pry-byebug (3.10.1)
7776
byebug (~> 11.0)
7877
pry (>= 0.13, < 0.15)
79-
racc (1.6.2)
78+
racc (1.8.1)
8079
rack (2.2.6.4)
8180
rack-test (2.1.0)
8281
rack (>= 1.3)
@@ -87,6 +86,7 @@ GEM
8786
loofah (~> 2.19, >= 2.19.1)
8887
rainbow (3.1.1)
8988
rake (13.0.6)
89+
regexp_parser (2.9.2)
9090
rspec (3.12.0)
9191
rspec-core (~> 3.12.0)
9292
rspec-expectations (~> 3.12.0)
@@ -100,22 +100,25 @@ GEM
100100
diff-lcs (>= 1.2.0, < 2.0)
101101
rspec-support (~> 3.12.0)
102102
rspec-support (3.12.0)
103-
rubocop (0.75.1)
104-
jaro_winkler (~> 1.5.1)
103+
rubocop (1.68.0)
104+
json (~> 2.3)
105+
language_server-protocol (>= 3.17.0)
105106
parallel (~> 1.10)
106-
parser (>= 2.6)
107+
parser (>= 3.3.0.2)
107108
rainbow (>= 2.2.2, < 4.0)
109+
regexp_parser (>= 2.4, < 3.0)
110+
rubocop-ast (>= 1.32.2, < 2.0)
108111
ruby-progressbar (~> 1.7)
109-
unicode-display_width (>= 1.4.0, < 1.7)
110-
rubocop-rspec (1.33.0)
111-
rubocop (>= 0.60.0)
112-
ruby-debug-ide (0.7.3)
113-
rake (>= 0.8.1)
112+
unicode-display_width (>= 2.4.0, < 3.0)
113+
rubocop-ast (1.36.1)
114+
parser (>= 3.3.1.0)
115+
rubocop-rspec (3.2.0)
116+
rubocop (~> 1.61)
114117
ruby-progressbar (1.13.0)
115118
thor (1.2.1)
116119
tzinfo (2.0.6)
117120
concurrent-ruby (~> 1.0)
118-
unicode-display_width (1.6.1)
121+
unicode-display_width (2.6.0)
119122
webrick (1.8.1)
120123

121124
PLATFORMS
@@ -131,15 +134,13 @@ DEPENDENCIES
131134
actionpack
132135
apollo-federation!
133136
appraisal!
134-
debase (= 0.2.5.beta2)
135137
graphql (~> 2.0.0)
136138
pry-byebug
137139
rack
138140
rake
139141
rspec
140-
rubocop (~> 0.75.0)
142+
rubocop (~> 1.68.0)
141143
rubocop-rspec
142-
ruby-debug-ide
143144
webrick
144145

145146
BUNDLED WITH

apollo-federation.gemspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@ Gem::Specification.new do |spec|
2222
'changelog_uri' => 'https://github.com/Gusto/apollo-federation-ruby/releases',
2323
'source_code_uri' => 'https://github.com/Gusto/apollo-federation-ruby',
2424
'bug_tracker_uri' => 'https://github.com/Gusto/apollo-federation-ruby/issues',
25+
'rubygems_mfa_required' => 'true',
2526
}
2627

2728
spec.files = `git ls-files bin lib *.md LICENSE`.split("\n")
2829

2930
spec.add_dependency 'graphql', '>= 1.10.14'
3031

31-
spec.add_runtime_dependency 'google-protobuf', '~> 3.22'
32+
spec.add_dependency 'google-protobuf', '~> 3.22'
3233

3334
spec.add_development_dependency 'actionpack'
3435
spec.add_development_dependency 'appraisal'
35-
spec.add_development_dependency 'debase', '0.2.5.beta2'
3636
spec.add_development_dependency 'pry-byebug'
3737
spec.add_development_dependency 'rack'
3838
spec.add_development_dependency 'rake'
3939
spec.add_development_dependency 'rspec'
40-
spec.add_development_dependency 'rubocop', '~> 0.75.0'
40+
spec.add_development_dependency 'rubocop', '~> 1.68.0'
4141
spec.add_development_dependency 'rubocop-rspec'
42-
spec.add_development_dependency 'ruby-debug-ide'
4342
spec.add_development_dependency 'webrick'
4443
end

example/graphql_server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rack'
44
require 'json'
5+
require 'ostruct'
56
require 'graphql'
67
require 'pry-byebug'
78
require 'apollo-federation'

lib/apollo-federation/entities_field.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def define_entities_field(possible_entities)
2626
end
2727
end
2828

29+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
2930
def _entities(representations:)
3031
final_result = Array.new(representations.size)
3132
grouped_references_with_indices =
@@ -85,6 +86,7 @@ def _entities(representations:)
8586
final_result
8687
end
8788
end
89+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
8890

8991
private
9092

0 commit comments

Comments
 (0)