mongoid-locker 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/danger-comment.yml +19 -0
- data/.github/workflows/danger.yml +9 -2
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/release.yml +30 -0
- data/.github/workflows/test.yml +10 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +134 -5
- data/.rubocop_todo.yml +45 -61
- data/.spellcheck.txt +78 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +11 -8
- data/README.md +36 -21
- data/RELEASING.md +19 -35
- data/Rakefile +22 -3
- data/UPGRADING.md +4 -6
- data/lib/mongoid/locker/version.rb +1 -1
- data/mongoid-locker.gemspec +1 -3
- data/script/release.rb +17 -0
- metadata +8 -4
- data/.github/workflows/rubocop.yml +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87d9c3f74f827716578524b7c0474e9f9416a4ed9cfb47936f1e8912abc22ee1
|
|
4
|
+
data.tar.gz: eb9789c962d8f8d92e68b741ad28e6dcc14de53ef9103bbedca64cb609e0cb4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ced5f2ae291fd48046cfdaaa3a069f71f84bb0e0078496b19e27436d166214df2c440c12fa4d637c7d99ec0bba2c195563e8ee622e6f47485cbe8a5c31d6f10b
|
|
7
|
+
data.tar.gz: d1eaf77d238353b5fc6e27db763e89c3367aa95faab6d5cea9e4a4695f1e639281535c48d800920937b6ab1cf90c1d6cfeac45417bd0a3bc88f17ecfbcbf815e
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Danger Comment
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: [Danger]
|
|
6
|
+
types: [completed]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
actions: read
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
comment:
|
|
15
|
+
name: Post Review Comment
|
|
16
|
+
uses: danger/danger-pr-comment/.github/workflows/danger-comment.yml@645e89bcc7be89ee7e8362166110b05cbced8e59 # v0.3.0
|
|
17
|
+
with:
|
|
18
|
+
base-branch: '*'
|
|
19
|
+
comment-empty: false
|
|
@@ -4,10 +4,17 @@ on:
|
|
|
4
4
|
pull_request:
|
|
5
5
|
types: [opened, reopened, edited, synchronize]
|
|
6
6
|
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
7
14
|
jobs:
|
|
8
15
|
danger:
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
name: Review Pull Request
|
|
17
|
+
uses: danger/danger-pr-comment/.github/workflows/danger-run.yml@645e89bcc7be89ee7e8362166110b05cbced8e59 # v0.3.0
|
|
11
18
|
with:
|
|
12
19
|
ruby-version: '3.4'
|
|
13
20
|
bundler-cache: true
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint:
|
|
17
|
+
name: Lint Code and Documentation
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 10
|
|
20
|
+
steps:
|
|
21
|
+
- name: Check Out Code
|
|
22
|
+
uses: actions/checkout@v7
|
|
23
|
+
- name: Set Up Ruby
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: '4.0'
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
- name: Run Lint
|
|
29
|
+
run: bundle exec rake lint
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: Optional release version overriding the checked-in version.
|
|
8
|
+
type: string
|
|
9
|
+
required: false
|
|
10
|
+
dry-run:
|
|
11
|
+
description: Check release prerequisites, such as RubyGems Trusted Publishing, without releasing.
|
|
12
|
+
type: boolean
|
|
13
|
+
default: false
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
release:
|
|
21
|
+
if: github.repository == 'mongoid/mongoid-locker' && github.ref == 'refs/heads/master'
|
|
22
|
+
uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.9.0
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: '3.3'
|
|
25
|
+
version: ${{ inputs.version }}
|
|
26
|
+
dry-run: ${{ inputs.dry-run }}
|
|
27
|
+
test: |
|
|
28
|
+
docker run --detach --name mongodb --publish 27017:27017 mongo:8.0
|
|
29
|
+
until docker exec mongodb mongosh --quiet --eval 'db.adminCommand({ping: 1})'; do sleep 1; done
|
|
30
|
+
bundle exec rake
|
data/.github/workflows/test.yml
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
name: Test
|
|
2
2
|
|
|
3
|
-
on:
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
concurrency:
|
|
8
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
9
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
4
10
|
|
|
5
11
|
jobs:
|
|
6
12
|
sharding:
|
|
7
13
|
name: Sharded collections (MongoDB ${{ matrix.mongo }})
|
|
8
14
|
runs-on: ubuntu-22.04
|
|
15
|
+
timeout-minutes: 20
|
|
9
16
|
strategy:
|
|
10
17
|
fail-fast: false
|
|
11
18
|
matrix:
|
|
@@ -23,7 +30,7 @@ jobs:
|
|
|
23
30
|
docker run -d --name locker-sharding -p 27028:27017 \
|
|
24
31
|
-v "$PWD/spec/integration/sharding/start.sh:/start.sh:ro" \
|
|
25
32
|
mongo:${{ matrix.mongo }} bash /start.sh
|
|
26
|
-
for
|
|
33
|
+
for _ in $(seq 1 60); do
|
|
27
34
|
if docker exec locker-sharding mongosh --quiet --eval 'if (db.adminCommand({listShards:1}).shards.length !== 1) throw new Error("Shard not ready")' >/dev/null 2>&1; then
|
|
28
35
|
exit 0
|
|
29
36
|
fi
|
|
@@ -53,6 +60,7 @@ jobs:
|
|
|
53
60
|
- { ruby: '4.0', mongo: '8.0', mongoid: '9', coverage: 'true' }
|
|
54
61
|
name: test (ruby=${{ matrix.ruby }}, mongo=${{ matrix.mongo }}, mongoid=${{ matrix.mongoid }})
|
|
55
62
|
runs-on: ubuntu-22.04
|
|
63
|
+
timeout-minutes: 20
|
|
56
64
|
services:
|
|
57
65
|
mongo:
|
|
58
66
|
image: mongo:${{ matrix.mongo }}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-md
|
|
3
|
+
- rubocop-prose
|
|
4
|
+
- rubocop-rake
|
|
5
|
+
- rubocop-rspec
|
|
6
|
+
- rubocop-spellcheck
|
|
7
|
+
- rubocop-yaml
|
|
8
|
+
|
|
9
|
+
inherit_from: ".rubocop_todo.yml"
|
|
10
|
+
|
|
1
11
|
AllCops:
|
|
2
|
-
SuggestExtensions:
|
|
12
|
+
SuggestExtensions: false
|
|
3
13
|
NewCops: enable
|
|
14
|
+
inherit_mode:
|
|
15
|
+
merge:
|
|
16
|
+
- Include
|
|
17
|
+
Include:
|
|
18
|
+
- ".github/**/*.yml"
|
|
19
|
+
- ".rubocop.yml"
|
|
20
|
+
Exclude:
|
|
21
|
+
- coverage/**/*
|
|
22
|
+
- pkg/**/*
|
|
23
|
+
- vendor/**/*
|
|
4
24
|
|
|
5
25
|
Lint/RaiseException:
|
|
6
26
|
Enabled: true
|
|
@@ -18,13 +38,122 @@ Style/HashTransformValues:
|
|
|
18
38
|
Enabled: true
|
|
19
39
|
|
|
20
40
|
RSpec/MultipleExpectations:
|
|
41
|
+
inherit_mode:
|
|
42
|
+
merge:
|
|
43
|
+
- Exclude
|
|
21
44
|
Enabled: false
|
|
45
|
+
Exclude:
|
|
46
|
+
- spec/release/release_spec.rb
|
|
22
47
|
|
|
23
48
|
RSpec/LeakyConstantDeclaration:
|
|
24
49
|
Enabled: false
|
|
25
50
|
|
|
26
|
-
|
|
51
|
+
YAML/Lint/InvalidSyntax:
|
|
52
|
+
Include:
|
|
53
|
+
- "**/*.yml"
|
|
54
|
+
- "**/*.yaml"
|
|
27
55
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
56
|
+
YAML/Lint/DuplicateKey:
|
|
57
|
+
Include:
|
|
58
|
+
- "**/*.yml"
|
|
59
|
+
- "**/*.yaml"
|
|
60
|
+
|
|
61
|
+
Naming/FileName:
|
|
62
|
+
inherit_mode:
|
|
63
|
+
merge:
|
|
64
|
+
- Exclude
|
|
65
|
+
Exclude:
|
|
66
|
+
- "**/*.md"
|
|
67
|
+
- ".github/workflows/*.yml"
|
|
68
|
+
- lib/mongoid-locker.rb
|
|
69
|
+
|
|
70
|
+
Style/OneClassPerFile:
|
|
71
|
+
inherit_mode:
|
|
72
|
+
merge:
|
|
73
|
+
- Exclude
|
|
74
|
+
Exclude:
|
|
75
|
+
- "**/*.md"
|
|
76
|
+
|
|
77
|
+
Style/Documentation:
|
|
78
|
+
inherit_mode:
|
|
79
|
+
merge:
|
|
80
|
+
- Exclude
|
|
81
|
+
Exclude:
|
|
82
|
+
- "**/*.md"
|
|
83
|
+
|
|
84
|
+
Lint/UselessAssignment:
|
|
85
|
+
inherit_mode:
|
|
86
|
+
merge:
|
|
87
|
+
- Exclude
|
|
88
|
+
Exclude:
|
|
89
|
+
- "**/*.md"
|
|
90
|
+
|
|
91
|
+
Style/MultilineBlockChain:
|
|
92
|
+
inherit_mode:
|
|
93
|
+
merge:
|
|
94
|
+
- Exclude
|
|
95
|
+
Exclude:
|
|
96
|
+
- "**/*.md"
|
|
97
|
+
|
|
98
|
+
Style/SymbolProc:
|
|
99
|
+
inherit_mode:
|
|
100
|
+
merge:
|
|
101
|
+
- Exclude
|
|
102
|
+
Exclude:
|
|
103
|
+
- "**/*.md"
|
|
104
|
+
|
|
105
|
+
Lint/Void:
|
|
106
|
+
inherit_mode:
|
|
107
|
+
merge:
|
|
108
|
+
- Exclude
|
|
109
|
+
Exclude:
|
|
110
|
+
- "**/*.md"
|
|
111
|
+
|
|
112
|
+
Markdown/HeadingCapitalization:
|
|
113
|
+
Enabled: true
|
|
114
|
+
Style: title_case
|
|
115
|
+
|
|
116
|
+
Prose/MaxLength:
|
|
117
|
+
Max: false
|
|
118
|
+
Exclude:
|
|
119
|
+
- LICENSE.txt
|
|
120
|
+
|
|
121
|
+
Spellcheck:
|
|
122
|
+
DictionaryFiles:
|
|
123
|
+
en:
|
|
124
|
+
- gem:rubocop-spellcheck/data/en/en.dic
|
|
125
|
+
- ".spellcheck.txt"
|
|
126
|
+
|
|
127
|
+
Spellcheck/Spelling:
|
|
128
|
+
Exclude:
|
|
129
|
+
- LICENSE.txt
|
|
130
|
+
|
|
131
|
+
Metrics/BlockLength:
|
|
132
|
+
inherit_mode:
|
|
133
|
+
merge:
|
|
134
|
+
- Exclude
|
|
135
|
+
Exclude:
|
|
136
|
+
- Gemfile
|
|
137
|
+
|
|
138
|
+
Layout/LineLength:
|
|
139
|
+
inherit_mode:
|
|
140
|
+
merge:
|
|
141
|
+
- Exclude
|
|
142
|
+
Exclude:
|
|
143
|
+
- ".github/workflows/*.yml"
|
|
144
|
+
|
|
145
|
+
# These shared contexts reset Mongoid::Locker's global configuration once per context.
|
|
146
|
+
RSpec/BeforeAfterAll:
|
|
147
|
+
inherit_mode:
|
|
148
|
+
merge:
|
|
149
|
+
- Exclude
|
|
150
|
+
Exclude:
|
|
151
|
+
- spec/support/configurations_shared_context.rb
|
|
152
|
+
|
|
153
|
+
# One release example verifies the tag, the next development commit, and their files together.
|
|
154
|
+
RSpec/ExampleLength:
|
|
155
|
+
inherit_mode:
|
|
156
|
+
merge:
|
|
157
|
+
- Exclude
|
|
158
|
+
Exclude:
|
|
159
|
+
- spec/release/release_spec.rb
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
#
|
|
2
|
+
# `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
|
|
3
|
+
# using RuboCop version 1.92.3.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count: 1
|
|
10
|
-
# Configuration parameters: Severity.
|
|
11
9
|
Gemspec/RequiredRubyVersion:
|
|
12
10
|
Exclude:
|
|
13
11
|
- 'mongoid-locker.gemspec'
|
|
14
12
|
|
|
15
|
-
#
|
|
13
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
14
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
|
15
|
+
Layout/ExtraSpacing:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'spec/support/configurations_shared_context.rb'
|
|
18
|
+
|
|
16
19
|
# Configuration parameters: AllowedMethods.
|
|
17
20
|
# AllowedMethods: enums
|
|
18
21
|
Lint/ConstantDefinitionInBlock:
|
|
@@ -20,46 +23,42 @@ Lint/ConstantDefinitionInBlock:
|
|
|
20
23
|
- 'spec/support/configurations_shared_context.rb'
|
|
21
24
|
- 'spec/test_examples_spec.rb'
|
|
22
25
|
|
|
23
|
-
# Offense count: 8
|
|
24
26
|
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
|
25
27
|
Lint/EmptyBlock:
|
|
26
28
|
Exclude:
|
|
27
29
|
- 'spec/support/locker_is_included_shared_examples.rb'
|
|
28
30
|
|
|
29
|
-
#
|
|
30
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
31
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
31
32
|
Metrics/AbcSize:
|
|
32
|
-
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'lib/mongoid/locker.rb'
|
|
35
|
+
- 'lib/mongoid/locker/wrapper.rb'
|
|
33
36
|
|
|
34
|
-
#
|
|
35
|
-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
37
|
+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
36
38
|
Metrics/MethodLength:
|
|
37
|
-
|
|
39
|
+
Exclude:
|
|
40
|
+
- 'lib/mongoid/locker.rb'
|
|
41
|
+
- 'lib/mongoid/locker/wrapper.rb'
|
|
38
42
|
|
|
39
|
-
#
|
|
40
|
-
# Configuration parameters: CountComments, CountAsOne.
|
|
43
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
|
41
44
|
Metrics/ModuleLength:
|
|
42
|
-
|
|
45
|
+
Exclude:
|
|
46
|
+
- 'lib/mongoid/locker.rb'
|
|
43
47
|
|
|
44
|
-
# Offense count: 2
|
|
45
48
|
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
46
49
|
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
|
47
50
|
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
48
51
|
Naming/FileName:
|
|
49
52
|
Exclude:
|
|
50
|
-
- 'Rakefile.rb'
|
|
51
|
-
- 'lib/mongoid-locker.rb'
|
|
52
53
|
- 'spec/mongoid-locker_spec.rb'
|
|
53
54
|
|
|
54
|
-
# Offense count: 1
|
|
55
55
|
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
|
|
56
56
|
# AllowedMethods: call
|
|
57
|
-
# WaywardPredicates: nonzero?
|
|
57
|
+
# WaywardPredicates: infinite?, nonzero?
|
|
58
58
|
Naming/PredicateMethod:
|
|
59
59
|
Exclude:
|
|
60
60
|
- 'lib/mongoid/locker/wrapper.rb'
|
|
61
61
|
|
|
62
|
-
# Offense count: 1
|
|
63
62
|
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
|
|
64
63
|
# NamePrefix: is_, has_, have_, does_
|
|
65
64
|
# ForbiddenPrefixes: is_, has_, have_, does_
|
|
@@ -67,34 +66,26 @@ Naming/PredicateMethod:
|
|
|
67
66
|
# MethodDefinitionMacros: define_method, define_singleton_method
|
|
68
67
|
Naming/PredicatePrefix:
|
|
69
68
|
Exclude:
|
|
70
|
-
- 'spec/**/*'
|
|
71
69
|
- 'lib/mongoid/locker.rb'
|
|
72
70
|
|
|
73
|
-
# Offense count: 2
|
|
74
71
|
RSpec/BeforeAfterAll:
|
|
75
72
|
Exclude:
|
|
76
|
-
- '**/spec/spec_helper.rb'
|
|
77
|
-
- '**/spec/rails_helper.rb'
|
|
78
|
-
- '**/spec/support/**/*.rb'
|
|
79
73
|
- 'spec/test_examples_spec.rb'
|
|
80
74
|
|
|
81
|
-
# Offense count: 1
|
|
82
75
|
# Configuration parameters: IgnoredMetadata.
|
|
83
76
|
RSpec/DescribeClass:
|
|
84
77
|
Exclude:
|
|
85
|
-
- '**/spec/features/**/*'
|
|
86
|
-
- '**/spec/requests/**/*'
|
|
87
|
-
- '**/spec/routing/**/*'
|
|
88
|
-
- '**/spec/system/**/*'
|
|
89
|
-
- '**/spec/views/**/*'
|
|
90
78
|
- 'spec/test_examples_spec.rb'
|
|
91
79
|
|
|
92
|
-
#
|
|
93
|
-
# Configuration parameters: CountAsOne.
|
|
80
|
+
# Configuration parameters: Max, CountAsOne.
|
|
94
81
|
RSpec/ExampleLength:
|
|
95
|
-
|
|
82
|
+
Exclude:
|
|
83
|
+
- 'spec/integration/mongoid-history/mongoid_history_spec.rb'
|
|
84
|
+
- 'spec/integration/sharding/mongoid/locker_spec.rb'
|
|
85
|
+
- 'spec/mongoid/locker_embedded_documents_spec.rb'
|
|
86
|
+
- 'spec/support/locker_is_included_shared_examples.rb'
|
|
87
|
+
- 'spec/test_examples_spec.rb'
|
|
96
88
|
|
|
97
|
-
# Offense count: 5
|
|
98
89
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
99
90
|
RSpec/IncludeExamples:
|
|
100
91
|
Exclude:
|
|
@@ -102,62 +93,47 @@ RSpec/IncludeExamples:
|
|
|
102
93
|
- 'spec/support/locker_is_included_shared_examples.rb'
|
|
103
94
|
- 'spec/support/locker_methods_shared_examples.rb'
|
|
104
95
|
|
|
105
|
-
# Offense count: 2
|
|
106
96
|
RSpec/LetSetup:
|
|
107
97
|
Exclude:
|
|
108
98
|
- 'spec/support/populate_database_shared_context.rb'
|
|
109
99
|
|
|
110
|
-
# Offense count: 12
|
|
111
100
|
# Configuration parameters: .
|
|
112
101
|
# SupportedStyles: have_received, receive
|
|
113
102
|
RSpec/MessageSpies:
|
|
114
103
|
EnforcedStyle: receive
|
|
115
104
|
|
|
116
|
-
#
|
|
117
|
-
# Configuration parameters: AllowSubject.
|
|
105
|
+
# Configuration parameters: AllowSubject, Max.
|
|
118
106
|
RSpec/MultipleMemoizedHelpers:
|
|
119
|
-
|
|
107
|
+
Exclude:
|
|
108
|
+
- 'spec/mongoid-locker_spec.rb'
|
|
109
|
+
- 'spec/support/configurations_shared_context.rb'
|
|
110
|
+
- 'spec/support/errors_shared_examples.rb'
|
|
120
111
|
|
|
121
|
-
# Offense count: 2
|
|
122
112
|
# Configuration parameters: AllowedPatterns.
|
|
123
113
|
# AllowedPatterns: ^expect_, ^assert_
|
|
124
114
|
RSpec/NoExpectationExample:
|
|
125
115
|
Exclude:
|
|
126
116
|
- 'spec/support/locker_is_included_shared_examples.rb'
|
|
127
117
|
|
|
128
|
-
# Offense count: 1
|
|
129
118
|
RSpec/RemoveConst:
|
|
130
119
|
Exclude:
|
|
131
120
|
- 'spec/support/locker_helpers.rb'
|
|
132
121
|
|
|
133
|
-
# Offense count: 1
|
|
134
122
|
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
|
|
135
123
|
# SupportedInflectors: default, active_support
|
|
136
124
|
RSpec/SpecFilePathFormat:
|
|
137
125
|
Exclude:
|
|
138
|
-
- '**/spec/routing/**/*'
|
|
139
126
|
- 'spec/mongoid-locker_spec.rb'
|
|
140
127
|
|
|
141
|
-
# Offense count: 1
|
|
142
128
|
RSpec/SubjectStub:
|
|
143
129
|
Exclude:
|
|
144
130
|
- 'spec/support/delegated_methods_shared_examples.rb'
|
|
145
131
|
|
|
146
|
-
# Offense count: 1
|
|
147
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
148
|
-
Style/CollectionQuerying:
|
|
149
|
-
Exclude:
|
|
150
|
-
- 'lib/mongoid/locker.rb'
|
|
151
|
-
|
|
152
|
-
# Offense count: 2
|
|
153
132
|
# Configuration parameters: AllowedConstants.
|
|
154
133
|
Style/Documentation:
|
|
155
134
|
Exclude:
|
|
156
|
-
- 'spec/**/*'
|
|
157
|
-
- 'test/**/*'
|
|
158
135
|
- 'lib/mongoid/locker.rb'
|
|
159
136
|
|
|
160
|
-
# Offense count: 4
|
|
161
137
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
162
138
|
# Configuration parameters: AllowSplatArgument.
|
|
163
139
|
Style/HashConversion:
|
|
@@ -165,18 +141,26 @@ Style/HashConversion:
|
|
|
165
141
|
- 'spec/support/locker_is_included_shared_examples.rb'
|
|
166
142
|
- 'spec/support/locker_methods_shared_examples.rb'
|
|
167
143
|
|
|
168
|
-
#
|
|
144
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
145
|
+
Style/IfUnlessModifier:
|
|
146
|
+
Exclude:
|
|
147
|
+
- 'spec/integration/sharding/mongoid/locker_spec.rb'
|
|
148
|
+
|
|
169
149
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
170
150
|
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
|
|
171
151
|
# SupportedStyles: predicate, comparison
|
|
172
152
|
Style/NumericPredicate:
|
|
173
153
|
Exclude:
|
|
174
|
-
- 'spec/**/*'
|
|
175
154
|
- 'lib/mongoid/locker.rb'
|
|
176
155
|
|
|
177
|
-
# Offense count: 7
|
|
178
156
|
# This cop supports safe autocorrection (--autocorrect).
|
|
179
|
-
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes,
|
|
157
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
180
158
|
# URISchemes: http, https
|
|
159
|
+
# AllowedPatterns: (?-mix:^\#)
|
|
181
160
|
Layout/LineLength:
|
|
182
|
-
|
|
161
|
+
Exclude:
|
|
162
|
+
- 'lib/mongoid/locker.rb'
|
|
163
|
+
- 'lib/mongoid/locker/wrapper.rb'
|
|
164
|
+
- 'mongoid-locker.gemspec'
|
|
165
|
+
- 'spec/integration/sharding/mongoid/locker_spec.rb'
|
|
166
|
+
- 'spec/test_examples_spec.rb'
|
data/.spellcheck.txt
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
activesupport
|
|
2
|
+
afeld
|
|
3
|
+
Aidan
|
|
4
|
+
amanfrinati
|
|
5
|
+
api
|
|
6
|
+
backoff
|
|
7
|
+
bbed
|
|
8
|
+
BSON
|
|
9
|
+
Bundler
|
|
10
|
+
cesarizu
|
|
11
|
+
chainable
|
|
12
|
+
CHANGELOG
|
|
13
|
+
Changelog
|
|
14
|
+
changelog
|
|
15
|
+
ClassMethods
|
|
16
|
+
commit's
|
|
17
|
+
config
|
|
18
|
+
Customizable
|
|
19
|
+
dblock
|
|
20
|
+
DocumentCouldNotGetLock
|
|
21
|
+
EmbeddedLockChild
|
|
22
|
+
EmbeddedLockParent
|
|
23
|
+
english
|
|
24
|
+
env
|
|
25
|
+
expr
|
|
26
|
+
Feldman
|
|
27
|
+
Fixnum
|
|
28
|
+
forwardable
|
|
29
|
+
Gemfile
|
|
30
|
+
gemspec
|
|
31
|
+
github
|
|
32
|
+
InvalidParameter
|
|
33
|
+
isdbgrid
|
|
34
|
+
JRuby
|
|
35
|
+
klass
|
|
36
|
+
linter
|
|
37
|
+
localTime
|
|
38
|
+
LockError
|
|
39
|
+
md
|
|
40
|
+
Mongoid
|
|
41
|
+
mongoid
|
|
42
|
+
MongoidHistory
|
|
43
|
+
MongoidLockerRelease
|
|
44
|
+
mongos
|
|
45
|
+
mooremo
|
|
46
|
+
msg
|
|
47
|
+
nchainani
|
|
48
|
+
ObjectId
|
|
49
|
+
param
|
|
50
|
+
pschrammel
|
|
51
|
+
Rakefile
|
|
52
|
+
randikabanura
|
|
53
|
+
rb
|
|
54
|
+
README
|
|
55
|
+
rsosag
|
|
56
|
+
RSpec
|
|
57
|
+
rspec
|
|
58
|
+
Rubinius
|
|
59
|
+
RuboCop
|
|
60
|
+
RubyDoc
|
|
61
|
+
RubyGems
|
|
62
|
+
saisrinivasan
|
|
63
|
+
scpike
|
|
64
|
+
SecureRandom
|
|
65
|
+
Sharded
|
|
66
|
+
sharded
|
|
67
|
+
ShardedLockDocument
|
|
68
|
+
sharding
|
|
69
|
+
SimpleCov
|
|
70
|
+
sivagollapalli
|
|
71
|
+
subclasses
|
|
72
|
+
tolsen
|
|
73
|
+
TTL
|
|
74
|
+
txt
|
|
75
|
+
utc
|
|
76
|
+
wuhuizuo
|
|
77
|
+
YAML
|
|
78
|
+
yml
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 2.3.1 (2026-11-24)
|
|
4
|
+
|
|
5
|
+
* [#115](https://github.com/mongoid/mongoid-locker/pull/115): Lint Markdown, YAML, and spelling with rubocop-md, rubocop-prose, rubocop-spellcheck, and rubocop-yaml in a separate Lint workflow, and clean up documentation - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#116](https://github.com/mongoid/mongoid-locker/pull/116): Run CI pushes only on the default branch, cancel superseded pull request runs, skip duplicate lint in the test matrix, and bound job times - [@dblock](https://github.com/dblock).
|
|
7
|
+
* [#117](https://github.com/mongoid/mongoid-locker/pull/117): Release with ruby-gem-release from a manually dispatched GitHub Actions workflow using RubyGems Trusted Publishing, with dry runs - [@dblock](https://github.com/dblock).
|
|
8
|
+
* [#119](https://github.com/mongoid/mongoid-locker/pull/119): Upgrade danger-pr-comment to 0.3.0 from the `danger` organization and skip empty Danger report comments - [@dblock](https://github.com/dblock).
|
|
9
|
+
* [#120](https://github.com/mongoid/mongoid-locker/pull/120): Date release headings as `YYYY-MM-DD`, matching earlier releases, instead of ruby-gem-release's default `YYYY/MM/DD` - [@dblock](https://github.com/dblock).
|
|
10
|
+
|
|
3
11
|
### 2.3.0 (2026-10-15)
|
|
4
12
|
|
|
5
13
|
* [#19](https://github.com/mongoid/mongoid-locker/issues/19): Add real sharded-cluster integration coverage for locking collections sharded by ranged and hashed `_id` - [@dblock](https://github.com/dblock).
|
|
@@ -9,6 +17,7 @@
|
|
|
9
17
|
* [#109](https://github.com/mongoid/mongoid-locker/pull/109): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock).
|
|
10
18
|
* [#109](https://github.com/mongoid/mongoid-locker/pull/109): Remove support for Ruby 2.x - [@dblock](https://github.com/dblock).
|
|
11
19
|
* [#109](https://github.com/mongoid/mongoid-locker/pull/109): Add support for Ruby 4.0 - [@dblock](https://github.com/dblock).
|
|
20
|
+
|
|
12
21
|
### 2.2.0 (2025-06-22)
|
|
13
22
|
|
|
14
23
|
* [#107](https://github.com/mongoid/mongoid-locker/pull/107): Revert introduction of `forwardable` to ensure compatibility with mongoid-history - [@scpike](https://github.com/scpike).
|
data/Gemfile
CHANGED
|
@@ -42,13 +42,16 @@ group :development, :test do
|
|
|
42
42
|
gem 'mongoid-compatibility'
|
|
43
43
|
gem 'mongoid-history'
|
|
44
44
|
gem 'rspec', '~> 3.9'
|
|
45
|
-
gem 'rubocop', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') ? '0.81.0' : '1.81.1'
|
|
46
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
|
|
47
|
-
gem 'rubocop-rake', '< 0.7'
|
|
48
|
-
gem 'rubocop-rspec', '1.38.1'
|
|
49
|
-
else
|
|
50
|
-
gem 'rubocop-rake', '>= 0.7'
|
|
51
|
-
gem 'rubocop-rspec', '>= 3.7'
|
|
52
|
-
end
|
|
53
45
|
gem 'simplecov', require: false
|
|
46
|
+
if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3')
|
|
47
|
+
gem 'commonmarker', '~> 2.10', require: false
|
|
48
|
+
gem 'rubocop', '~> 1.92'
|
|
49
|
+
gem 'rubocop-md', '~> 3.0', require: false
|
|
50
|
+
gem 'rubocop-prose', '~> 0.2', require: false
|
|
51
|
+
gem 'rubocop-rake', '~> 0.7', require: false
|
|
52
|
+
gem 'rubocop-rspec', '~> 3.10', require: false
|
|
53
|
+
gem 'rubocop-spellcheck', '~> 0.2', require: false
|
|
54
|
+
gem 'rubocop-yaml', '~> 0.1.0', require: false
|
|
55
|
+
gem 'ruby-gem-release', '0.9.0', require: false
|
|
56
|
+
end
|
|
54
57
|
end
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Mongoid-Locker
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/rb/mongoid-locker)
|
|
4
|
-
[](https://github.com/mongoid/mongoid-locker/actions/workflows/test.yml?query=branch%3Amaster)
|
|
5
|
-
[](https://coveralls.io/github/mongoid/mongoid-locker?branch=master)
|
|
3
|
+
[](https://badge.fury.io/rb/mongoid-locker) [](https://github.com/mongoid/mongoid-locker/actions/workflows/test.yml?query=branch%3Amaster) [](https://coveralls.io/github/mongoid/mongoid-locker?branch=master)
|
|
6
4
|
|
|
7
5
|
Document-level optimistic locking for MongoDB via Mongoid. Mongoid-Locker is an easy way to ensure only one process can perform a certain operation on a document at a time.
|
|
8
6
|
|
|
@@ -11,6 +9,7 @@ Document-level optimistic locking for MongoDB via Mongoid. Mongoid-Locker is an
|
|
|
11
9
|
**NOTE:** Please refer to [1-x-stable](https://github.com/mongoid/mongoid-locker/tree/1-x-stable) branch for `1.x.x` documentation. See the [UPGRADING](UPGRADING.md) guide and [CHANGELOG](CHANGELOG.md) for an overview of the changes.
|
|
12
10
|
|
|
13
11
|
[Tested](https://github.com/mongoid/mongoid-locker/actions) against:
|
|
12
|
+
|
|
14
13
|
- MRI: `3.x`, `4.x`
|
|
15
14
|
- JRuby `9.1.17.0`, `9.2.11.1`
|
|
16
15
|
- Mongoid: `5`, `6`, `7`, `8`, `9`
|
|
@@ -71,8 +70,10 @@ If you select a particular child before locking, keep its ID and retrieve it aga
|
|
|
71
70
|
|
|
72
71
|
Alternatively, `parent.with_lock(reload: false)` preserves existing in-memory embedded references, but does not refresh the parent or its children after acquiring the lock. Use it only when you deliberately want to work with the state already loaded; acquiring the lock does not make that state current.
|
|
73
72
|
|
|
74
|
-
### Customizable
|
|
73
|
+
### Customizable `locking_name` and `locked_at` Field Names
|
|
74
|
+
|
|
75
75
|
By default, Locker uses fields with `:locking_name` and `:locked_at` names which should be defined in a model.
|
|
76
|
+
|
|
76
77
|
```ruby
|
|
77
78
|
class User
|
|
78
79
|
include Mongoid::Document
|
|
@@ -84,6 +85,7 @@ end
|
|
|
84
85
|
```
|
|
85
86
|
|
|
86
87
|
Use `Mongoid::Locker.configure` to setup parameters which used by Locker for all models where it's included.
|
|
88
|
+
|
|
87
89
|
```ruby
|
|
88
90
|
Mongoid::Locker.configure do |config|
|
|
89
91
|
config.locking_name_field = :global_locking_name
|
|
@@ -100,6 +102,7 @@ end
|
|
|
100
102
|
```
|
|
101
103
|
|
|
102
104
|
The `locker` method in your model accepts options to setup parameters for the model.
|
|
105
|
+
|
|
103
106
|
```ruby
|
|
104
107
|
class User
|
|
105
108
|
include Mongoid::Document
|
|
@@ -108,37 +111,42 @@ class User
|
|
|
108
111
|
field :locker_locking_name, type: String
|
|
109
112
|
field :locker_locked_at, type: Time
|
|
110
113
|
|
|
111
|
-
locker
|
|
114
|
+
locker locking_name_field: :locker_locking_name,
|
|
112
115
|
locked_at_field: :locker_locked_at
|
|
113
116
|
end
|
|
114
117
|
```
|
|
115
118
|
|
|
116
|
-
### Available
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
119
|
+
### Available Parameters
|
|
120
|
+
|
|
121
|
+
| parameter | default | options | description |
|
|
122
|
+
| --- | --- | --- | --- |
|
|
123
|
+
| locking_name_field | `:locking_name` | any field name | field where name of locking is storing, must be of type `String` |
|
|
124
|
+
| locked_at_field | `:locked_at` | any field name | field where it is storing the time of beginning a lock of a document, must be of type `Time` |
|
|
125
|
+
| lock_timeout | `5` | | within this time (in seconds) a document is considered as locked |
|
|
126
|
+
| locker_write_concern | `{ w: 1 }` | see [MongoDB Write Concern](https://docs.mongodb.com/manual/reference/write-concern/#write-concern-specification) | a write concern only used for lock and unlock operations |
|
|
127
|
+
| maximum_backoff | `60.0` | | the highest timeout (in seconds) between retries to lock a document, reaching that value `#with_lock` method raises `Mongoid::Locker::Errors::DocumentCouldNotGetLock` |
|
|
128
|
+
| backoff_algorithm | `:exponential_backoff` | `:locked_at_backoff` or [custom algorithm](#custom-backoff_algorithm-and-locking_name_generator) | algorithm used for timeout calculating between retries to lock a document |
|
|
129
|
+
| locking_name_generator | `:secure_locking_name` | [custom generator](#custom-backoff_algorithm-and-locking_name_generator) | generator used to generate unique name of a lock |
|
|
126
130
|
|
|
127
131
|
For instances of a class where `Mongoid::Locker` is included, all parameters of a class are available for reading.
|
|
132
|
+
|
|
128
133
|
```ruby
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
document.lock_timeout
|
|
135
|
+
# => 5
|
|
131
136
|
```
|
|
132
137
|
|
|
133
|
-
### Custom
|
|
138
|
+
### Custom `backoff_algorithm` and `locking_name_generator`
|
|
139
|
+
|
|
134
140
|
A method which is defined in `Mongoid::Locker` are available in a class where it is included.
|
|
135
141
|
|
|
136
142
|
Method `#with_lock` passes to the methods a document to which apply `#with_lock` and a hash of options. The hash may look like this:
|
|
143
|
+
|
|
137
144
|
```ruby
|
|
138
|
-
|
|
145
|
+
{ retries: Infinity, reload: true, attempt: 0, locking_name: '71c1ccd4-72d9-4a83-bbed-adf65803bd5d' }
|
|
139
146
|
```
|
|
140
147
|
|
|
141
|
-
A custom backoff
|
|
148
|
+
A custom backoff algorithm **must return** a value more or equal `maximum_backoff` value to force `#with_lock` quit trying to lock a document, otherwise `#with_lock` will be trying to lock a document `INFINITY` times.
|
|
149
|
+
|
|
142
150
|
```ruby
|
|
143
151
|
Mongoid::Locker.configure do |config|
|
|
144
152
|
config.backoff_algorithm = :custom_backoff
|
|
@@ -154,6 +162,7 @@ end
|
|
|
154
162
|
```
|
|
155
163
|
|
|
156
164
|
A custom locking name generator **must return** a string to secure uniqueness name of locking.
|
|
165
|
+
|
|
157
166
|
```ruby
|
|
158
167
|
class User
|
|
159
168
|
include Mongoid::Document
|
|
@@ -167,9 +176,11 @@ class User
|
|
|
167
176
|
def self.custom_locking_name(_doc, _opts)
|
|
168
177
|
SecureRandom.uuid
|
|
169
178
|
end
|
|
179
|
+
end
|
|
170
180
|
```
|
|
171
181
|
|
|
172
182
|
## Testing with RSpec
|
|
183
|
+
|
|
173
184
|
Please see examples in [test_examples_spec.rb](spec/test_examples_spec.rb) file.
|
|
174
185
|
|
|
175
186
|
### Sharded Collections
|
|
@@ -191,8 +202,12 @@ docker rm locker-sharding
|
|
|
191
202
|
|
|
192
203
|
Use a dedicated test database: these tests drop and recreate their collection. Without `SHARDED_MONGODB_URI`, they are skipped by the normal suite. CI starts the cluster and runs them separately on MongoDB 6.0 and 8.0.
|
|
193
204
|
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md), [CHANGELOG.md](CHANGELOG.md), [UPGRADING.md](UPGRADING.md), and [RELEASING.md](RELEASING.md).
|
|
208
|
+
|
|
194
209
|
## Copyright & License
|
|
195
210
|
|
|
196
211
|
Copyright (c) 2012-2020 Aidan Feldman & Contributors
|
|
197
212
|
|
|
198
|
-
MIT License, see [LICENSE](LICENSE.txt) for more information.
|
|
213
|
+
MIT License, see [LICENSE.txt](LICENSE.txt) for more information.
|
data/RELEASING.md
CHANGED
|
@@ -1,51 +1,35 @@
|
|
|
1
|
-
# Releasing Mongoid
|
|
1
|
+
# Releasing Mongoid-Locker
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Use the upstream checkout on a clean `master`, verify `origin` points to `mongoid/mongoid-locker`, and run `git pull --ff-only`. Review existing CI results for supported platforms. Use patch versions for fixes, minor versions for backward-compatible features, and major versions for breaking changes.
|
|
3
|
+
Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.9.0 through a manually dispatched [Release workflow](.github/workflows/release.yml). Keep the `ruby-gem-release` gem in [Gemfile](Gemfile) and the reusable workflow in `release.yml` pinned to the same version. The workflow publishes through RubyGems Trusted Publishing, so no RubyGems API key or one-time password is needed. It only runs from `master` in `mongoid/mongoid-locker`. The local Bundler `rake release`, `release:rubygem_push`, and `release:source_control_push` tasks are disabled.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
## One-Time Setup
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
bundle install
|
|
11
|
-
bundle exec rspec
|
|
12
|
-
bundle exec rubocop
|
|
13
|
-
git add CHANGELOG.md lib/mongoid/locker/version.rb RELEASING.md
|
|
14
|
-
git commit -m "Preparing for release, 2.3.0."
|
|
15
|
-
git push origin master
|
|
16
|
-
```
|
|
7
|
+
Before the first automated release, a maintainer must:
|
|
17
8
|
|
|
18
|
-
|
|
9
|
+
1. Create the GitHub environment `release` in `mongoid/mongoid-locker`, for example with `gh api --method PUT repos/mongoid/mongoid-locker/environments/release`, and restrict its deployment branches to `master`. Add required reviewers to require maintainer approval before publication.
|
|
10
|
+
2. At [mongoid-locker's trusted publishers](https://rubygems.org/gems/mongoid-locker/trusted_publishers), add a GitHub Actions publisher with repository owner `mongoid`, repository `mongoid-locker`, workflow filename `release.yml`, environment `release`, and the separate workflow repository owner `dblock` and repository `ruby-gem-release`.
|
|
11
|
+
3. Allow GitHub Actions to push release commits and `v*` tags to `master`. See the upstream [setup and permissions guidance](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#one-time-setup).
|
|
19
12
|
|
|
20
|
-
|
|
13
|
+
Verify the setup without publishing with a [dry run](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#dry-run), which never edits files, builds, pushes, or publishes:
|
|
21
14
|
|
|
22
15
|
```sh
|
|
23
|
-
|
|
16
|
+
gh workflow run release.yml --repo mongoid/mongoid-locker --ref master -f dry-run=true
|
|
24
17
|
```
|
|
25
18
|
|
|
26
|
-
|
|
19
|
+
## Prepare
|
|
20
|
+
|
|
21
|
+
Start with a clean, up-to-date `master` and verify that the latest [CI checks](https://github.com/mongoid/mongoid-locker/actions) pass. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes. Check `VERSION` in [lib/mongoid/locker/version.rb](lib/mongoid/locker/version.rb) and the matching `(Next)` heading in [CHANGELOG.md](CHANGELOG.md), and change both in a pull request if needed, or pass a `version` override when dispatching. The workflow dates the `(Next)` heading using `YYYY/MM/DD` and removes the `* Your contribution here.` placeholder; a section without notes cannot be released.
|
|
22
|
+
|
|
23
|
+
Release automation requires MRI Ruby 3.3 or newer; the release dependency and tasks are skipped on older Ruby versions and JRuby. Release specs in [spec/release](spec/release) run the actual release tasks against a local fixture with the [ruby-gem-release RSpec helpers](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/testing.md), without contacting RubyGems or GitHub.
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
## Publish
|
|
29
26
|
|
|
30
27
|
```sh
|
|
31
|
-
|
|
32
|
-
notes="$(mktemp)"
|
|
33
|
-
awk -v version="$version" '
|
|
34
|
-
/^### / {
|
|
35
|
-
if (found) exit
|
|
36
|
-
if ($2 == version) found = 1
|
|
37
|
-
next
|
|
38
|
-
}
|
|
39
|
-
found { print }
|
|
40
|
-
' CHANGELOG.md > "$notes"
|
|
41
|
-
gh release create "v$version" --repo mongoid/mongoid-locker --verify-tag --title "$version" --notes-file "$notes" --latest
|
|
42
|
-
rm "$notes"
|
|
43
|
-
curl --fail --silent --show-error "https://rubygems.org/api/v2/rubygems/mongoid-locker/versions/$version.json"
|
|
44
|
-
gh release view "v$version" --repo mongoid/mongoid-locker
|
|
28
|
+
gh workflow run release.yml --repo mongoid/mongoid-locker --ref master
|
|
45
29
|
```
|
|
46
30
|
|
|
47
|
-
|
|
31
|
+
Pass `-f version=x.y.z` to release a different version. Dispatching starts a real release; do not merge into `master` while it runs. The workflow prepares the release commit, starts MongoDB 8.0, runs lint and specs on Ruby 3.3, builds the gem, preserves recovery artifacts, publishes to RubyGems, pushes the release commit and `v` tag, and creates a GitHub Release with the changelog notes and the gem attached. It then increments the patch version, adds a new `(Next)` section, and pushes the next development commit. Verify the published version on [RubyGems](https://rubygems.org/gems/mongoid-locker), the tag, the [GitHub Release](https://github.com/mongoid/mongoid-locker/releases), and the next development commit.
|
|
48
32
|
|
|
49
|
-
##
|
|
33
|
+
## Recover a Partial Release
|
|
50
34
|
|
|
51
|
-
|
|
35
|
+
Inspect the failed run, RubyGems, remote commits and tags, and the GitHub Release before retrying. Publication may have succeeded even if a later step failed. Never move a published tag or republish a version with different contents. Use the run's retained recovery artifacts and the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts).
|
data/Rakefile
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'bundler/setup'
|
|
5
5
|
require 'bundler/gem_tasks'
|
|
6
|
+
|
|
7
|
+
if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
|
|
8
|
+
Gem.loaded_specs.key?('ruby-gem-release')
|
|
9
|
+
require_relative 'script/release'
|
|
10
|
+
MongoidLockerRelease.workflow.install_tasks
|
|
11
|
+
|
|
12
|
+
%w[release release:rubygem_push release:source_control_push].each do |name|
|
|
13
|
+
Rake::Task[name].clear
|
|
14
|
+
desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
|
|
15
|
+
task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
6
18
|
require 'rake'
|
|
7
19
|
|
|
8
20
|
require 'rspec/core'
|
|
@@ -11,7 +23,14 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
|
11
23
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
12
24
|
end
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
lint = RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
|
|
27
|
+
Gem.loaded_specs.key?('rubocop')
|
|
28
|
+
if lint
|
|
29
|
+
require 'rubocop/rake_task'
|
|
30
|
+
RuboCop::RakeTask.new(:rubocop)
|
|
31
|
+
|
|
32
|
+
desc 'Lint Ruby, Markdown, YAML, and spelling'
|
|
33
|
+
task lint: :rubocop
|
|
34
|
+
end
|
|
16
35
|
|
|
17
|
-
task default: %i[rubocop spec]
|
|
36
|
+
task default: lint ? %i[rubocop spec] : %i[spec]
|
data/UPGRADING.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
## Upgrading Mongoid-Locker
|
|
2
2
|
|
|
3
|
-
## Upgrading
|
|
3
|
+
## Upgrading To 2.0.0
|
|
4
4
|
|
|
5
|
-
Mongoid-Locker supports only `5`, `6` and `7` versions of Mongoid.
|
|
6
|
-
Since this version `Mongoid::Locker` uses unique name of locking and time is set by MongoDB. `Mongoid::Locker` no longer uses `locked_until` field and this field may be deleted with `User.all.unset(:locked_until)`. You must define new `locking_name` field of `String` type.
|
|
5
|
+
Mongoid-Locker supports only `5`, `6` and `7` versions of Mongoid. Since this version `Mongoid::Locker` uses unique name of locking and time is set by MongoDB. `Mongoid::Locker` no longer uses `locked_until` field and this field may be deleted with `User.all.unset(:locked_until)`. You must define new `locking_name` field of `String` type.
|
|
7
6
|
|
|
8
7
|
```ruby
|
|
9
8
|
class User
|
|
@@ -15,10 +14,9 @@ class User
|
|
|
15
14
|
end
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
The options `:timeout` and `retry_sleep` of `#with_lock` method was deprecated and have no effect. For details see [RubyDoc.info](https://www.rubydoc.info/gems/mongoid-locker/2.0.0/Mongoid/Locker#with_lock-instance_method).
|
|
19
|
-
If you handle `Mongoid::Locker::LockError` error then this error should be renamed to `Mongoid::Locker::Errors::DocumentCouldNotGetLock`.
|
|
17
|
+
The options `:timeout` and `retry_sleep` of `#with_lock` method was deprecated and have no effect. For details see [RubyDoc.info](https://www.rubydoc.info/gems/mongoid-locker/2.0.0/Mongoid/Locker#with_lock-instance_method). If you handle `Mongoid::Locker::LockError` error then this error should be renamed to `Mongoid::Locker::Errors::DocumentCouldNotGetLock`.
|
|
20
18
|
|
|
21
|
-
### Upgrading
|
|
19
|
+
### Upgrading To 1.0.0
|
|
22
20
|
|
|
23
21
|
`Mongoid::Locker` no longer defines `locked_at` and `locked_until` fields when included. You must define these fields manually.
|
|
24
22
|
|
data/mongoid-locker.gemspec
CHANGED
data/script/release.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ruby-gem-release/changelog'
|
|
4
|
+
require 'ruby-gem-release/workflow/ruby_gem'
|
|
5
|
+
|
|
6
|
+
# Builds the ruby-gem-release workflow used by the Rakefile, the Release GitHub Actions workflow, and spec/release.
|
|
7
|
+
module MongoidLockerRelease
|
|
8
|
+
def self.workflow(**options)
|
|
9
|
+
RubyGemRelease::Workflow::RubyGem.new(
|
|
10
|
+
version: RubyGemRelease::Version::RubyConstant.new(path: 'lib/mongoid/locker/version.rb', constant: 'VERSION'),
|
|
11
|
+
changelog: RubyGemRelease::Changelog::Intridea.new(
|
|
12
|
+
placeholder: '* Your contribution here.', date_format: '%Y-%m-%d'
|
|
13
|
+
),
|
|
14
|
+
**options
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-locker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aidan Feldman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mongoid
|
|
@@ -38,13 +38,16 @@ executables: []
|
|
|
38
38
|
extensions: []
|
|
39
39
|
extra_rdoc_files: []
|
|
40
40
|
files:
|
|
41
|
+
- ".github/workflows/danger-comment.yml"
|
|
41
42
|
- ".github/workflows/danger.yml"
|
|
42
|
-
- ".github/workflows/
|
|
43
|
+
- ".github/workflows/lint.yml"
|
|
44
|
+
- ".github/workflows/release.yml"
|
|
43
45
|
- ".github/workflows/test.yml"
|
|
44
46
|
- ".gitignore"
|
|
45
47
|
- ".rspec"
|
|
46
48
|
- ".rubocop.yml"
|
|
47
49
|
- ".rubocop_todo.yml"
|
|
50
|
+
- ".spellcheck.txt"
|
|
48
51
|
- CHANGELOG.md
|
|
49
52
|
- CONTRIBUTING.md
|
|
50
53
|
- Dangerfile
|
|
@@ -62,6 +65,7 @@ files:
|
|
|
62
65
|
- lib/mongoid/locker/version.rb
|
|
63
66
|
- lib/mongoid/locker/wrapper.rb
|
|
64
67
|
- mongoid-locker.gemspec
|
|
68
|
+
- script/release.rb
|
|
65
69
|
homepage: https://github.com/mongoid/mongoid-locker
|
|
66
70
|
licenses:
|
|
67
71
|
- MIT
|
|
@@ -82,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
86
|
- !ruby/object:Gem::Version
|
|
83
87
|
version: '0'
|
|
84
88
|
requirements: []
|
|
85
|
-
rubygems_version: 3.5.
|
|
89
|
+
rubygems_version: 3.5.22
|
|
86
90
|
signing_key:
|
|
87
91
|
specification_version: 4
|
|
88
92
|
summary: Document-level optimistic locking for MongoDB via Mongoid.
|