-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathaction.yml
More file actions
178 lines (165 loc) · 6.01 KB
/
action.yml
File metadata and controls
178 lines (165 loc) · 6.01 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Test Gem
description: Tests a specific Gem
inputs:
gem:
description: Gem to test
required: true
type: string
ruby:
description: Ruby version to use
required: true
type: string
yard:
description: Run YARD documentation
required: false
type: boolean
default: false
rubocop:
description: Run Rubocop
required: false
type: boolean
default: false
coverage:
description: Enforce test coverage
required: false
type: boolean
default: false
minimum_coverage:
description: Minimum test coverage
required: false
type: string
default: 85
build:
description: Build gem
required: false
type: boolean
default: false
latest:
description: Build against the latest version of the gem
required: false
type: boolean
default: false
runs:
using: composite
steps:
- name: Setup
id: setup
shell: bash
run: |
# 🛠️ Setup 🛠️
dir=$(find . -iname '${{ inputs.gem }}.gemspec' -exec dirname {} \;)
echo "gem_dir=${dir}" >> $GITHUB_OUTPUT
# We install multiple ruby versions here, and that makes for some
# annoying bundler conflicts when we get to the JRuby step. Removing
# the lockfile slows things down a bit, but we should still get most
# of the benefits of bundler caching.
rm -f "${dir}/Gemfile.lock"
echo "cache_key=mri" >> $GITHUB_OUTPUT
if [[ "${{ inputs.ruby }}" == "jruby" ]]; then
echo "cache_key=jruby" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.ruby }}" == "truffleruby" ]]; then
echo "cache_key=truffleruby" >> $GITHUB_OUTPUT
fi
echo "appraisals=false" >> $GITHUB_OUTPUT
if [[ "${{ inputs.latest }}" != "true" ]]; then
if [[ -f "${dir}/Appraisals" ]]; then
echo "appraisals=true" >> $GITHUB_OUTPUT
fi
fi
# Install ImageMagick for active_storage testing.
# Unfortunately, as of ubuntu-24.04, ImageMagick is no longer pre-installed in Github Actions.
# See https://github.com/actions/runner-images/issues/10772
- name: Install ImageMagick for active_storage testing
if: "${{ inputs.gem == 'opentelemetry-instrumentation-active_storage' }}"
shell: bash
run: sudo apt update && sudo apt install -y imagemagick
# Install ruby and bundle dependencies and cache!
# ...but not for appraisals, sadly.
- name: Install Ruby ${{ inputs.ruby }} with dependencies
if: "${{ steps.setup.outputs.appraisals == 'false' }}"
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: "${{ inputs.ruby }}"
working-directory: "${{ steps.setup.outputs.gem_dir }}"
bundler-cache: true
cache-version: "${{ inputs.ruby }}-${{ steps.setup.outputs.cache_key }}"
# If we're using appraisals, do it all manually.
- name: Install Ruby ${{ inputs.ruby }} without dependencies
if: "${{ steps.setup.outputs.appraisals == 'true' }}"
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: "${{ inputs.ruby }}"
working-directory: "${{ steps.setup.outputs.gem_dir }}"
- name: Install dependencies and generate appraisals
if: "${{ steps.setup.outputs.appraisals == 'true' }}"
shell: bash
run: |
# 💎 Install dependencies and generate appraisals 💎
bundle install --quiet --jobs=3 --retry=4
bundle exec appraisal clean
bundle exec appraisal generate
working-directory: "${{ steps.setup.outputs.gem_dir }}"
- name: Test Gem
shell: bash
run: |
# 🍿 Test Gem 🍿
if [[ -f "Appraisals" ]]; then
for i in `bundle exec appraisal list | sed 's/-/_/g' `; do
echo "::group::🔎 Appraising ${i}"
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle install --quiet --jobs=3 --retry=4 && \
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle show && \
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle exec rake test || exit
echo "::endgroup::"
done
else
bundle exec rake test
fi
working-directory: "${{ steps.setup.outputs.gem_dir }}"
env:
TEST_KAFKA_HOST: "127.0.0.1"
TEST_KAFKA_PORT: 29092
TEST_MYSQL_HOST: "127.0.0.1"
TEST_MYSQL_PORT: 3306
TEST_MYSQL_USER: mysql
TEST_MYSQL_PASSWORD: mysql
TEST_POSTGRES_PASSWORD: postgres
TEST_POSTGRES_USER: postgres
TEST_POSTGRES_HOST: localhost
TEST_POSTGRES_PORT: 5432
TEST_POSTGRES_DB: postgres
TEST_MEMCACHED_HOST: localhost
TEST_MEMCACHED_PORT: 11211
TEST_MONGODB_HOST: localhost
TEST_MONGODB_PORT: 27017
TEST_RABBITMQ_HOST: localhost
TEST_RABBITMQ_PORT: 5672
TEST_RABBITMQ_URL: amqp://guest:guest@localhost:5672
TEST_REDIS_HOST: localhost
TEST_REDIS_PORT: 6379
- name: YARD
shell: bash
if: "${{ inputs.yard == 'true' }}"
run: |
# 📄 Yard Docs 📄
bundle exec rake yard
working-directory: "${{ steps.setup.outputs.gem_dir }}"
- name: Rubocop
shell: bash
if: "${{ inputs.rubocop == 'true' }}"
run: |
# 🤖 Rubocop 🤖
bundle exec rake rubocop
working-directory: "${{ steps.setup.outputs.gem_dir }}"
- name: Coverage
shell: bash
# This starts a new simplecov run which tracks nothing of its own,
# but merges with the existing coverage reports generated during testing.
run: 'bundle exec ruby -e ''require "simplecov"; SimpleCov.minimum_coverage(${{ inputs.minimum_coverage }}); SimpleCov.collate Dir["coverage/**/.resultset.json"];'''
working-directory: "${{ steps.setup.outputs.gem_dir }}"
- name: Build Gem
shell: bash
if: "${{ inputs.build == 'true' }}"
run: |
# 📦 Build Gem 📦
gem build ${{ inputs.gem }}.gemspec
working-directory: "${{ steps.setup.outputs.gem_dir }}"