-
Notifications
You must be signed in to change notification settings - Fork 157
157 lines (149 loc) · 6.08 KB
/
Copy pathci.yml
File metadata and controls
157 lines (149 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: CI
on:
push:
branches: [main, 1.x, beta]
pull_request: {}
workflow_dispatch: {}
concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Run standardrb
run: |
bundle exec standardrb --no-fix --format progress || {
echo "::error::Lint failed. Almost everything standard flags is auto-fixable — run 'bundle exec standardrb --fix' locally and push the result."
exit 1
}
test:
name: "Tests - ${{ matrix.ruby }} | ${{ matrix.gemfile }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
# Every cell is listed explicitly rather than built from a cross product
# plus `exclude:`. An exclude row naming a gemfile that does not exist is
# silently ignored, which is how this matrix carried four dead rows for a
# "rails_7_0_graphiti_rails.gemfile" that was never generated. A bad
# gemfile path in an include row fails the job loudly instead.
#
# Ruby coverage per Rails version tracks that version's own supported
# range; see Appraisals for the matching sqlite3 constraints.
matrix:
include:
# No Rails - the library on its own, across every supported Ruby
- { ruby: "3.2", gemfile: Gemfile, appraisal: false }
- { ruby: "3.3", gemfile: Gemfile, appraisal: false }
- { ruby: "3.4", gemfile: Gemfile, appraisal: false }
- { ruby: "4.0", gemfile: Gemfile, appraisal: false }
- { ruby: ruby-head, gemfile: Gemfile, appraisal: false }
# Rails 7.1 - the floor
- { ruby: "3.2", gemfile: gemfiles/rails_7_1.gemfile, appraisal: true }
- { ruby: "3.4", gemfile: gemfiles/rails_7_1.gemfile, appraisal: true }
- { ruby: "4.0", gemfile: gemfiles/rails_7_1.gemfile, appraisal: true }
# Rails 7.2
- { ruby: "3.2", gemfile: gemfiles/rails_7_2.gemfile, appraisal: true }
- { ruby: "3.4", gemfile: gemfiles/rails_7_2.gemfile, appraisal: true }
- { ruby: "4.0", gemfile: gemfiles/rails_7_2.gemfile, appraisal: true }
- { ruby: ruby-head, gemfile: gemfiles/rails_7_2.gemfile, appraisal: true }
# Rails 8.0
- { ruby: "3.2", gemfile: gemfiles/rails_8_0.gemfile, appraisal: true }
- { ruby: "3.4", gemfile: gemfiles/rails_8_0.gemfile, appraisal: true }
- { ruby: "4.0", gemfile: gemfiles/rails_8_0.gemfile, appraisal: true }
- { ruby: ruby-head, gemfile: gemfiles/rails_8_0.gemfile, appraisal: true }
# Rails 8.1
- { ruby: "3.2", gemfile: gemfiles/rails_8_1.gemfile, appraisal: true }
- { ruby: "3.4", gemfile: gemfiles/rails_8_1.gemfile, appraisal: true }
- { ruby: "4.0", gemfile: gemfiles/rails_8_1.gemfile, appraisal: true }
- { ruby: ruby-head, gemfile: gemfiles/rails_8_1.gemfile, appraisal: true }
continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
steps:
- name: Set up Appraisal
if: matrix.appraisal
run: echo "APPRAISAL_INITIALIZED=true" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rspec
# spec_helper narrows "bundle exec rspec" to spec/integration/rails when
# APPRAISAL_INITIALIZED is set, so the step above never runs the library
# suite. This is the only cell that runs it against a pinned Rails.
- name: Run the library suite against this Rails
if: matrix.appraisal
run: env -u APPRAISAL_INITIALIZED bundle exec rspec
example-app:
name: "Example app (employee_directory)"
runs-on: ubuntu-latest
# The example app lives in its own repo and can lag behind; it is an
# integration canary, not a merge gate.
continue-on-error: true
env:
GRAPHITI_PATH: ${{ github.workspace }}/graphiti
BUNDLE_FROZEN: "false" # the path override rewrites the checked-in lockfile
defaults:
run:
working-directory: employee_directory
steps:
- uses: actions/checkout@v4
with:
path: graphiti
- uses: actions/checkout@v4
with:
repository: graphiti-api/employee_directory
path: employee_directory
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
- name: Bundle against this graphiti
run: bundle install
- name: Run the example app suite
run: |
bundle exec rails db:test:prepare
bundle exec rspec
examples:
name: "Examples (plain ruby, sinatra)"
runs-on: ubuntu-latest
# In-tree examples run against the working copy via their path: Gemfiles.
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
- name: Run the plain ruby example
working-directory: examples/plain_ruby
run: |
bundle install
bundle exec ruby index.rb
- name: Run the sinatra example
working-directory: examples/sinatra
run: |
bundle install
bundle exec ruby smoke.rb
publish:
name: Release
runs-on: ubuntu-latest
# Only main auto-releases. Beta releases are cut by manually running
# "Generate New Release" with the beta branch selected.
if: github.ref == 'refs/heads/main'
needs: [lint, test]
steps:
- name: Dispatch Release
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Generate New Release
# Without an explicit ref the dispatch runs against the default
# branch rather than the branch that triggered it.
ref: ${{ github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}