Skip to content

Commit 98d83bb

Browse files
committed
✨ Modernize gem
- new 20 year cert for signing - documentation on GitHub pages - appraisals for CI - GitHub actions w/ 100% test coverage
1 parent 3c14cec commit 98d83bb

File tree

136 files changed

+7654
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+7654
-379
lines changed

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3+
{
4+
"name": "Ruby",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/ruby:1-3-bookworm",
7+
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
// "features": {},
10+
11+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
12+
// "forwardPorts": [],
13+
14+
// Use 'postCreateCommand' to run commands after the container is created.
15+
// "postCreateCommand": "ruby --version",
16+
17+
// Configure tool-specific properties.
18+
"customizations" : {
19+
"jetbrains" : {
20+
"backend" : "RubyMine"
21+
}
22+
},
23+
24+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
25+
// "remoteUser": "root"
26+
}

.envrc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Run any command in this library's bin/ without the bin/ prefix!
2+
PATH_add bin
3+
4+
# Only add things to this file that should be shared with the team.
5+
6+
# **dotenv** (See end of file for .env.local integration)
7+
# .env would override anything in this file, if enabled.
8+
# .env is a DOCKER standard, and if we use it, it would be in deployed, or DOCKER, environments.
9+
# Override and customize anything below in your own .env.local
10+
# If you are using dotenv and not direnv,
11+
# copy the following `export` statements to your own .env file.
12+
13+
### General Ruby ###
14+
# Turn off Ruby Warnings about deprecated code
15+
# export RUBYOPT="-W0"
16+
17+
### External Testing Controls
18+
export K_SOUP_COV_DO=true # Means you want code coverage
19+
# Available formats are html, xml, rcov, lcov, json, tty
20+
export K_SOUP_COV_COMMAND_NAME="RSpec Coverage"
21+
export K_SOUP_COV_FORMATTERS="html,tty"
22+
export K_SOUP_COV_MIN_BRANCH=100 # Means you want to enforce X% branch coverage
23+
export K_SOUP_COV_MIN_LINE=100 # Means you want to enforce X% line coverage
24+
export K_SOUP_COV_MIN_HARD=true # Means you want the build to fail if the coverage thresholds are not met
25+
export K_SOUP_COV_MULTI_FORMATTERS=true
26+
export K_SOUP_COV_OPEN_BIN= # Means don't try to open coverage results in browser
27+
export MAX_ROWS=1 # Setting for simplecov-console gem for tty output, limits to the worst N rows of bad coverage
28+
29+
# Internal Debugging Controls
30+
export DEBUG=false # do not allow byebug statements (override in .env.local)
31+
32+
# Concurrently developing the rubocop-lts suite?
33+
export RUBOCOP_LTS_LOCAL=false
34+
35+
# .env would override anything in this file, if `dotenv` is uncommented below.
36+
# .env is a DOCKER standard, and if we use it, it would be in deployed, or DOCKER, environments,
37+
# and that is why we generally want to leave it commented out.
38+
# dotenv
39+
40+
# .env.local will override anything in this file.
41+
dotenv_if_exists .env.local

.github/workflows/ancient.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: MRI 2.3, 2.4, 2.5 (EOL)
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
- '*-stable'
11+
tags:
12+
- '!*' # Do not execute on tags
13+
pull_request:
14+
branches:
15+
- '*'
16+
# Allow manually triggering the workflow.
17+
workflow_dispatch:
18+
19+
# Cancels all previous workflow runs for the same branch that have not yet completed.
20+
concurrency:
21+
# The concurrency group contains the workflow name and the branch name.
22+
group: "${{ github.workflow }}-${{ github.ref }}"
23+
cancel-in-progress: true
24+
25+
jobs:
26+
test:
27+
name: Specs ${{ matrix.ruby }} ${{ matrix.appraisal }}${{ matrix.name_extra || '' }}
28+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
29+
runs-on: ubuntu-22.04
30+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
31+
env: # $BUNDLE_GEMFILE must be set at job level, so it is set for all steps
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}.gemfile
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include:
37+
# Ruby 2.3
38+
- ruby: "ruby-2.3"
39+
appraisal: "ruby-2-3"
40+
exec_cmd: "rake test"
41+
gemfile: "Appraisal.root"
42+
rubygems: "3.3.27"
43+
bundler: "2.3.27"
44+
45+
# Ruby 2.4
46+
- ruby: "ruby-2.4"
47+
appraisal: "ruby-2-4"
48+
exec_cmd: "rake test"
49+
gemfile: "Appraisal.root"
50+
rubygems: "3.3.27"
51+
bundler: "2.3.27"
52+
53+
# Ruby 2.5
54+
- ruby: "ruby-2.5"
55+
appraisal: "ruby-2-5"
56+
exec_cmd: "rake test"
57+
gemfile: "Appraisal.root"
58+
rubygems: "3.3.27"
59+
bundler: "2.3.27"
60+
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
65+
- name: Setup Ruby & RubyGems
66+
uses: ruby/setup-ruby@v1
67+
with:
68+
ruby-version: ${{ matrix.ruby }}
69+
rubygems: ${{ matrix.rubygems }}
70+
bundler: ${{ matrix.bundler }}
71+
bundler-cache: false
72+
73+
# Raw `bundle` will use the BUNDLE_GEMFILE set to matrix.gemfile (i.e. Appraisal.root)
74+
# We need to do this first to get appraisal installed.
75+
# NOTE: This does not use the primary Gemfile at all.
76+
- name: Install Root Appraisal
77+
run: bundle
78+
- name: Appraisal for ${{ matrix.appraisal }}
79+
run: bundle exec appraisal ${{ matrix.appraisal }} bundle
80+
- name: Tests for ${{ matrix.ruby }} via ${{ matrix.exec_cmd }}
81+
run: bundle exec appraisal ${{ matrix.appraisal }} bundle exec ${{ matrix.exec_cmd }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ main, "*-stable" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ main, "*-stable" ]
20+
schedule:
21+
- cron: '35 1 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'ruby' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v3
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v3
57+
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
60+
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
64+
65+
#- run: |
66+
# make bootstrap
67+
# make release
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v3

.github/workflows/coverage.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Test Coverage
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
env:
8+
K_SOUP_COV_MIN_BRANCH: 100
9+
K_SOUP_COV_MIN_LINE: 100
10+
K_SOUP_COV_MIN_HARD: true
11+
K_SOUP_COV_FORMATTERS: "html,xml,rcov,lcov,json,tty"
12+
K_SOUP_COV_DO: true
13+
K_SOUP_COV_MULTI_FORMATTERS: true
14+
K_SOUP_COV_COMMAND_NAME: "RSpec Coverage"
15+
16+
on:
17+
push:
18+
branches:
19+
- 'main'
20+
- '*-stable'
21+
tags:
22+
- '!*' # Do not execute on tags
23+
pull_request:
24+
branches:
25+
- '*'
26+
# Allow manually triggering the workflow.
27+
workflow_dispatch:
28+
29+
# Cancels all previous workflow runs for the same branch that have not yet completed.
30+
concurrency:
31+
# The concurrency group contains the workflow name and the branch name.
32+
group: "${{ github.workflow }}-${{ github.ref }}"
33+
cancel-in-progress: true
34+
35+
jobs:
36+
coverage:
37+
name: Code Coverage on ${{ matrix.ruby }}@current
38+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
39+
runs-on: ubuntu-latest
40+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
41+
env: # $BUNDLE_GEMFILE must be set at job level, so it is set for all steps
42+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}.gemfile
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
# Coverage
48+
- ruby: "ruby"
49+
appraisal: "coverage"
50+
exec_cmd: "rake test"
51+
gemfile: "Appraisal.root"
52+
rubygems: latest
53+
bundler: latest
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Ruby & RubyGems
60+
uses: ruby/setup-ruby@v1
61+
with:
62+
ruby-version: "${{ matrix.ruby }}"
63+
rubygems: "${{ matrix.rubygems }}"
64+
bundler: "${{ matrix.bundler }}"
65+
bundler-cache: false
66+
67+
# Raw `bundle` will use the BUNDLE_GEMFILE set to matrix.gemfile (i.e. Appraisal.root)
68+
# We need to do this first to get appraisal installed.
69+
# NOTE: This does not use the primary Gemfile at all.
70+
- name: Install Root Appraisal
71+
run: bundle
72+
- name: Appraisal for ${{ matrix.appraisal }}
73+
run: bundle exec appraisal ${{ matrix.appraisal }} bundle
74+
- name: Tests for ${{ matrix.ruby }}@current via ${{ matrix.exec_cmd }}
75+
run: bundle exec appraisal ${{ matrix.appraisal }} bundle exec ${{ matrix.exec_cmd }}
76+
77+
# Do SaaS coverage uploads first
78+
- name: Upload coverage to Coveralls
79+
uses: coverallsapp/github-action@master
80+
with:
81+
github-token: ${{ secrets.GITHUB_TOKEN }}
82+
continue-on-error: ${{ matrix.experimental != 'false' }}
83+
84+
- name: Upload coverage to QLTY
85+
uses: qltysh/qlty-action/coverage@main
86+
with:
87+
token: ${{secrets.QLTY_COVERAGE_TOKEN}}
88+
files: coverage/.resultset.json
89+
continue-on-error: ${{ matrix.experimental != 'false' }}
90+
91+
# Build will fail here if coverage upload fails
92+
# which will hopefully be noticed for the lack of code coverage comments
93+
- name: Upload coverage to CodeCov
94+
uses: codecov/codecov-action@v5
95+
with:
96+
fail_ci_if_error: true # optional (default = false)
97+
token: ${{ secrets.CODECOV_TOKEN }}
98+
verbose: true # optional (default = false)
99+
100+
# Then PR comments
101+
- name: Code Coverage Summary Report
102+
uses: irongut/[email protected]
103+
if: ${{ github.event_name == 'pull_request' }}
104+
with:
105+
filename: ./coverage/coverage.xml
106+
badge: true
107+
fail_below_min: true
108+
format: markdown
109+
hide_branch_rate: false
110+
hide_complexity: true
111+
indicators: true
112+
output: both
113+
thresholds: '100 100'
114+
continue-on-error: ${{ matrix.experimental != 'false' }}
115+
116+
- name: Add Coverage PR Comment
117+
uses: marocchino/sticky-pull-request-comment@v2
118+
if: ${{ github.event_name == 'pull_request' }}
119+
with:
120+
recreate: true
121+
path: code-coverage-results.md
122+
continue-on-error: ${{ matrix.experimental != 'false' }}

0 commit comments

Comments
 (0)