pg_multitenant_schemas 0.2.2 โ 0.3.6
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/.agent.md +54 -0
- data/.rubocop.yml +7 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +58 -2
- data/DELIVERY_SUMMARY.md +318 -0
- data/GITHUB_ACTIONS_QUICK_START.md +110 -0
- data/GITHUB_ACTIONS_SETUP.md +313 -0
- data/GITHUB_ACTIONS_SUMMARY.md +231 -0
- data/LICENSE.txt +1 -1
- data/LOCAL_TESTING_SUMMARY.md +30 -13
- data/README.md +4 -4
- data/READY_TO_RELEASE.md +308 -0
- data/RELEASE_NOTES.md +194 -0
- data/RELEASE_STEPS.md +122 -0
- data/WORKFLOW_FIXES.md +188 -0
- data/docs/index.html +929 -0
- data/docs/testing_rails_tasks.md +128 -0
- data/lib/pg_multitenant_schemas/configuration.rb +7 -1
- data/lib/pg_multitenant_schemas/context.rb +92 -3
- data/lib/pg_multitenant_schemas/migration_schema_operations.rb +99 -5
- data/lib/pg_multitenant_schemas/migrator.rb +66 -9
- data/lib/pg_multitenant_schemas/rails/controller_concern.rb +81 -6
- data/lib/pg_multitenant_schemas/rails/generators/install_generator.rb +27 -0
- data/lib/pg_multitenant_schemas/rails/generators/tenant_migration_generator.rb +30 -0
- data/lib/pg_multitenant_schemas/rails/model_concern.rb +3 -3
- data/lib/pg_multitenant_schemas/rails/railtie.rb +31 -1
- data/lib/pg_multitenant_schemas/schema_switcher.rb +107 -7
- data/lib/pg_multitenant_schemas/tasks/tenant_tasks.rake +0 -3
- data/lib/pg_multitenant_schemas/tenant_resolver.rb +3 -3
- data/lib/pg_multitenant_schemas/ui/app/assets/stylesheets/pg_multitenant_schemas/ui/application.css +94 -0
- data/lib/pg_multitenant_schemas/ui/app/controllers/pg_multitenant_schemas/ui/tenants_controller.rb +130 -0
- data/lib/pg_multitenant_schemas/ui/app/views/layouts/pg_multitenant_schemas/ui/application.html.erb +29 -0
- data/lib/pg_multitenant_schemas/ui/app/views/pg_multitenant_schemas/ui/tenants/index.html.erb +85 -0
- data/lib/pg_multitenant_schemas/ui/app/views/pg_multitenant_schemas/ui/tenants/migration_status.html.erb +45 -0
- data/lib/pg_multitenant_schemas/ui/app/views/pg_multitenant_schemas/ui/tenants/new.html.erb +50 -0
- data/lib/pg_multitenant_schemas/ui/config/routes.rb +20 -0
- data/lib/pg_multitenant_schemas/ui/engine.rb +49 -0
- data/lib/pg_multitenant_schemas/ui.rb +9 -0
- data/lib/pg_multitenant_schemas/version.rb +1 -1
- data/lib/pg_multitenant_schemas.rb +155 -29
- data/pg_multitenant_schemas.gemspec +18 -12
- data/pre-release-check.sh +46 -0
- metadata +44 -17
- data/lib/pg_multitenant_schemas/tasks/pg_multitenant_schemas.rake +0 -65
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# GitHub Actions CI/CD Setup Guide
|
|
2
|
+
|
|
3
|
+
> ๐ Automated deployment workflows for `pg_multitenant_schemas` gem
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This setup provides **fully automated CI/CD pipelines** for your Ruby gem with:
|
|
8
|
+
|
|
9
|
+
- โ
**Automated Testing** - Run tests across Ruby 3.0-3.3 and PostgreSQL 12-15
|
|
10
|
+
- โ
**Automatic Publishing** - Push to RubyGems on version bumps
|
|
11
|
+
- โ
**GitHub Releases** - Auto-create release notes and tags
|
|
12
|
+
- โ
**Documentation Hosting** - Deploy to GitHub Pages automatically
|
|
13
|
+
- โ
**GitHub Packages** - Backup package registry
|
|
14
|
+
- โ
**Security Scanning** - Dependency vulnerability checks
|
|
15
|
+
|
|
16
|
+
## Workflows Created
|
|
17
|
+
|
|
18
|
+
### 1. **test.yml** - Test Suite
|
|
19
|
+
**Triggers:** Push to main/develop, all Pull Requests
|
|
20
|
+
|
|
21
|
+
**What it does:**
|
|
22
|
+
- Runs RSpec tests on Ruby 3.0, 3.1, 3.2, 3.3
|
|
23
|
+
- Tests against PostgreSQL 12, 13, 14, 15 (all combinations)
|
|
24
|
+
- Runs syntax checks and YARD documentation generation
|
|
25
|
+
- Uploads coverage reports to Codecov
|
|
26
|
+
- Publishes test results as GitHub check
|
|
27
|
+
|
|
28
|
+
**Key features:**
|
|
29
|
+
- Matrix testing (4 Ruby versions ร 4 PostgreSQL versions = 16 test runs)
|
|
30
|
+
- Automatic coverage report uploads
|
|
31
|
+
- Test result annotation on PRs
|
|
32
|
+
- RuboCop linting (optional)
|
|
33
|
+
|
|
34
|
+
**Status Checks:**
|
|
35
|
+
- Shows as โ
in PR if all tests pass
|
|
36
|
+
- Blocks merge if tests fail (configurable)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### 2. **deploy.yml** - Auto-Deploy to RubyGems
|
|
41
|
+
**Triggers:** Push to main when `version.rb` changes
|
|
42
|
+
|
|
43
|
+
**What it does:**
|
|
44
|
+
1. Detects if version changed (`lib/pg_multitenant_schemas/version.rb`)
|
|
45
|
+
2. Builds the gem package
|
|
46
|
+
3. Publishes to **RubyGems.org** (production registry)
|
|
47
|
+
4. Publishes to **GitHub Packages** (backup)
|
|
48
|
+
5. Creates Git tag (e.g., `v0.3.0`)
|
|
49
|
+
6. Creates GitHub Release with changelog
|
|
50
|
+
|
|
51
|
+
**How it works:**
|
|
52
|
+
```
|
|
53
|
+
You update version.rb to 0.3.1
|
|
54
|
+
โ
|
|
55
|
+
Push to main
|
|
56
|
+
โ
|
|
57
|
+
GitHub Actions detects version change
|
|
58
|
+
โ
|
|
59
|
+
Runs all tests
|
|
60
|
+
โ
|
|
61
|
+
โ
Tests pass โ Publishes to RubyGems
|
|
62
|
+
โ Tests fail โ Stops, notifies you
|
|
63
|
+
โ
|
|
64
|
+
Automatically creates release
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Important:** Only publishes if tests pass โ
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### 3. **pages.yml** - Deploy Docs to GitHub Pages
|
|
72
|
+
**Triggers:** Push to main when `docs/` changes
|
|
73
|
+
|
|
74
|
+
**What it does:**
|
|
75
|
+
- Copies `docs/index.html` to GitHub Pages
|
|
76
|
+
- Includes markdown documentation as reference
|
|
77
|
+
- Makes docs available at: `https://rubenpazch.github.io/pg_multitenant_schemas/`
|
|
78
|
+
|
|
79
|
+
**GitHub Pages Setup Required:**
|
|
80
|
+
1. Go to GitHub repo โ Settings โ Pages
|
|
81
|
+
2. Select "Deploy from a branch"
|
|
82
|
+
3. Branch: `gh-pages`
|
|
83
|
+
4. Folder: `/ (root)`
|
|
84
|
+
5. Save
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### 4. **security.yml** - Security Scanning
|
|
89
|
+
**Triggers:** Every push to main, weekly schedule
|
|
90
|
+
|
|
91
|
+
**What it does:**
|
|
92
|
+
- Bundler audit (CVE vulnerability scanning)
|
|
93
|
+
- Dependency freshness checks
|
|
94
|
+
- Brakeman (Rails security scanner)
|
|
95
|
+
- Secret detection (prevents leaked API keys)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Setup Instructions
|
|
100
|
+
|
|
101
|
+
### โ
Step 1: Set Up RubyGems API Key
|
|
102
|
+
|
|
103
|
+
1. Go to https://rubygems.org โ Sign in โ Settings
|
|
104
|
+
2. Click "API Access" or "API Keys"
|
|
105
|
+
3. Create new API key (or use existing)
|
|
106
|
+
4. Copy the API key
|
|
107
|
+
|
|
108
|
+
5. In GitHub repo: Settings โ Secrets and variables โ Actions
|
|
109
|
+
6. Click "New repository secret"
|
|
110
|
+
7. Name: `RUBYGEMS_API_KEY`
|
|
111
|
+
8. Value: (paste API key from RubyGems)
|
|
112
|
+
9. Click "Add secret"
|
|
113
|
+
|
|
114
|
+
โ
**Secret is now encrypted and only used during deploy**
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### โ
Step 2: Enable GitHub Pages
|
|
119
|
+
|
|
120
|
+
1. Go to GitHub repo โ Settings โ Pages
|
|
121
|
+
2. Under "Build and deployment":
|
|
122
|
+
- Source: Select "GitHub Actions"
|
|
123
|
+
- (Workflows will deploy automatically)
|
|
124
|
+
3. Save
|
|
125
|
+
|
|
126
|
+
โ
**Pages will be available at:**
|
|
127
|
+
```
|
|
128
|
+
https://rubenpazch.github.io/pg_multitenant_schemas/
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### โ
Step 3: Configure Branch Protection (Optional)
|
|
134
|
+
|
|
135
|
+
Require tests to pass before merging:
|
|
136
|
+
|
|
137
|
+
1. Settings โ Branches โ Add rule
|
|
138
|
+
2. Branch name pattern: `main`
|
|
139
|
+
3. Check "Require status checks to pass before merging"
|
|
140
|
+
4. Check "Require branches to be up to date before merging"
|
|
141
|
+
5. Save
|
|
142
|
+
|
|
143
|
+
โ
**Now PRs must pass tests to merge**
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## How to Use
|
|
148
|
+
|
|
149
|
+
### Publishing a New Version
|
|
150
|
+
|
|
151
|
+
1. **Update version:**
|
|
152
|
+
```bash
|
|
153
|
+
# Edit lib/pg_multitenant_schemas/version.rb
|
|
154
|
+
VERSION = "0.3.1"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
2. **Update CHANGELOG.md:**
|
|
158
|
+
```markdown
|
|
159
|
+
## [0.3.1] - 2024-01-17
|
|
160
|
+
### Added
|
|
161
|
+
- New feature X
|
|
162
|
+
### Fixed
|
|
163
|
+
- Bug Y
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
3. **Push to main:**
|
|
167
|
+
```bash
|
|
168
|
+
git add -A
|
|
169
|
+
git commit -m "Bump version to 0.3.1"
|
|
170
|
+
git push origin main
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
4. **GitHub Actions automatically:**
|
|
174
|
+
- โ
Runs all tests
|
|
175
|
+
- โ
Publishes to RubyGems
|
|
176
|
+
- โ
Creates GitHub Release
|
|
177
|
+
- โ
Deploys docs
|
|
178
|
+
- โ
Creates Git tag
|
|
179
|
+
|
|
180
|
+
โ
**Done! No manual publishing needed.**
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### Monitoring Deployments
|
|
185
|
+
|
|
186
|
+
1. Go to repo โ Actions
|
|
187
|
+
2. See all workflow runs
|
|
188
|
+
3. Click workflow to see details
|
|
189
|
+
4. Each step shows logs
|
|
190
|
+
|
|
191
|
+
**Example workflow run:**
|
|
192
|
+
```
|
|
193
|
+
โ
test (Ruby 3.3, PG 15)
|
|
194
|
+
โ
test (Ruby 3.2, PG 15)
|
|
195
|
+
โ
... 14 more tests ...
|
|
196
|
+
โ
publish-rubygems
|
|
197
|
+
โ
create-release
|
|
198
|
+
โ
deploy-pages
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### Troubleshooting
|
|
204
|
+
|
|
205
|
+
**Issue: Deploy workflow didn't run**
|
|
206
|
+
- Check: Was version.rb changed?
|
|
207
|
+
- Check: Are you pushing to `main` branch?
|
|
208
|
+
- Solution: Version change is only trigger
|
|
209
|
+
|
|
210
|
+
**Issue: RubyGems publish failed**
|
|
211
|
+
- Check: Is RUBYGEMS_API_KEY secret set?
|
|
212
|
+
- Check: Are tests passing?
|
|
213
|
+
- Solution: Check Actions โ Deploy workflow logs
|
|
214
|
+
|
|
215
|
+
**Issue: Tests are failing**
|
|
216
|
+
- Check: Pull request shows failing tests
|
|
217
|
+
- Go to: Actions โ Test workflow โ Details
|
|
218
|
+
- Check logs for error
|
|
219
|
+
|
|
220
|
+
**Issue: GitHub Pages not showing**
|
|
221
|
+
- Check: Go to Settings โ Pages
|
|
222
|
+
- Check: Is "GitHub Actions" selected as source?
|
|
223
|
+
- Check: Did pages workflow complete? (Actions tab)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Secrets Reference
|
|
228
|
+
|
|
229
|
+
| Secret | Where to Get | Where to Configure |
|
|
230
|
+
|--------|-------------|-------------------|
|
|
231
|
+
| `RUBYGEMS_API_KEY` | https://rubygems.org โ Settings โ API Keys | Repo Settings โ Secrets |
|
|
232
|
+
| `GITHUB_TOKEN` | Automatic (GitHub provides) | Auto-configured |
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Workflow Details
|
|
237
|
+
|
|
238
|
+
### Test Matrix
|
|
239
|
+
```
|
|
240
|
+
Ruby versions: 3.0, 3.1, 3.2, 3.3
|
|
241
|
+
PostgreSQL: 12, 13, 14, 15
|
|
242
|
+
|
|
243
|
+
Total: 4 ร 4 = 16 parallel test runs
|
|
244
|
+
Average time: ~5 minutes
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Deploy Conditions
|
|
248
|
+
```
|
|
249
|
+
Trigger: Push to main with version.rb change
|
|
250
|
+
Tests pass? โ YES โ Build & publish
|
|
251
|
+
โ NO โ Stop (notify via email)
|
|
252
|
+
|
|
253
|
+
Publish to:
|
|
254
|
+
1. RubyGems.org (primary)
|
|
255
|
+
2. GitHub Packages (backup)
|
|
256
|
+
3. GitHub Release (docs)
|
|
257
|
+
4. GitHub Pages (HTML site)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Best Practices
|
|
263
|
+
|
|
264
|
+
โ
**Always bump version in version.rb for new releases**
|
|
265
|
+
- Example: `VERSION = "0.3.1"`
|
|
266
|
+
|
|
267
|
+
โ
**Update CHANGELOG.md with changes**
|
|
268
|
+
- Used in GitHub Release notes
|
|
269
|
+
|
|
270
|
+
โ
**Write descriptive commit messages**
|
|
271
|
+
- Shows in deployment logs
|
|
272
|
+
|
|
273
|
+
โ
**Test locally before pushing**
|
|
274
|
+
- Run `bundle exec rspec` locally first
|
|
275
|
+
|
|
276
|
+
โ
**Review GitHub Pages URL**
|
|
277
|
+
- Update README.md to link to docs
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## File Summary
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
.github/workflows/
|
|
285
|
+
โโโ test.yml - Run tests (triggered by push/PR)
|
|
286
|
+
โโโ deploy.yml - Publish gem (triggered by version change)
|
|
287
|
+
โโโ pages.yml - Deploy docs (triggered by docs/ change)
|
|
288
|
+
โโโ security.yml - Security checks (scheduled + push)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Quick Reference
|
|
294
|
+
|
|
295
|
+
| Action | Result |
|
|
296
|
+
|--------|--------|
|
|
297
|
+
| Push to main | Tests run + Results shown in Actions |
|
|
298
|
+
| Change version.rb | Auto-publishes gem to RubyGems |
|
|
299
|
+
| Merge PR to main | Tests must pass (branch protection) |
|
|
300
|
+
| Update docs/ | Auto-deploys to GitHub Pages |
|
|
301
|
+
| Weekly schedule | Security scans run |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Next Steps
|
|
306
|
+
|
|
307
|
+
1. โ
Set RUBYGEMS_API_KEY secret
|
|
308
|
+
2. โ
Enable GitHub Pages
|
|
309
|
+
3. โ
(Optional) Set branch protection
|
|
310
|
+
4. โ
Try pushing a change to main
|
|
311
|
+
5. โ
Check Actions tab to see workflows run
|
|
312
|
+
|
|
313
|
+
**That's it! Your gem now auto-deploys.** ๐
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# โ
GitHub Actions Setup Complete
|
|
2
|
+
|
|
3
|
+
## ๐ฏ What Was Created
|
|
4
|
+
|
|
5
|
+
### **Workflow Files** (`.github/workflows/`)
|
|
6
|
+
```
|
|
7
|
+
โโโ test.yml โญ
|
|
8
|
+
โ โโโ Runs tests on Ruby 3.0-3.3 + PostgreSQL 12-15 (16 combinations)
|
|
9
|
+
โ Triggers: Every push to main & all PRs
|
|
10
|
+
โ
|
|
11
|
+
โโโ deploy.yml โญ
|
|
12
|
+
โ โโโ Auto-publishes gem when version.rb changes
|
|
13
|
+
โ Targets: RubyGems.org + GitHub Packages
|
|
14
|
+
โ Includes: Auto git tag + GitHub Release creation
|
|
15
|
+
โ
|
|
16
|
+
โโโ pages.yml โญ
|
|
17
|
+
โ โโโ Deploys HTML docs to GitHub Pages
|
|
18
|
+
โ URL: https://rubenpazch.github.io/pg_multitenant_schemas/
|
|
19
|
+
โ
|
|
20
|
+
โโโ security.yml โญ
|
|
21
|
+
โ โโโ Weekly + push-triggered security scans
|
|
22
|
+
โ Checks: CVE vulnerabilities, dependencies, secrets
|
|
23
|
+
โ
|
|
24
|
+
โโโ main.yml (existing)
|
|
25
|
+
โ โโโ Legacy workflow
|
|
26
|
+
โ
|
|
27
|
+
โโโ release.yml (existing)
|
|
28
|
+
โโโ Legacy workflow
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### **Documentation Files**
|
|
32
|
+
```
|
|
33
|
+
โโโ GITHUB_ACTIONS_SETUP.md (7.3 KB)
|
|
34
|
+
โ โโโ Complete step-by-step setup guide with troubleshooting
|
|
35
|
+
โ
|
|
36
|
+
โโโ GITHUB_ACTIONS_QUICK_START.md (2.3 KB)
|
|
37
|
+
โโโ One-page quick reference for publishing releases
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## ๐ How It Works Now
|
|
43
|
+
|
|
44
|
+
### **Automatic Release Flow**
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
Step 1: You update version.rb
|
|
48
|
+
โโ> VERSION = "0.3.1"
|
|
49
|
+
|
|
50
|
+
Step 2: Push to main
|
|
51
|
+
โโ> git push origin main
|
|
52
|
+
|
|
53
|
+
Step 3: GitHub Actions detects change
|
|
54
|
+
โ
|
|
55
|
+
โโ> โ
test.yml runs (16 tests)
|
|
56
|
+
โ โโ Ruby 3.0 + PostgreSQL 12-15
|
|
57
|
+
โ โโ Ruby 3.1 + PostgreSQL 12-15
|
|
58
|
+
โ โโ Ruby 3.2 + PostgreSQL 12-15
|
|
59
|
+
โ โโ Ruby 3.3 + PostgreSQL 12-15
|
|
60
|
+
โ
|
|
61
|
+
โโ> If all pass:
|
|
62
|
+
โ
|
|
63
|
+
โโ> โ
deploy.yml
|
|
64
|
+
โ โโ Builds gem package
|
|
65
|
+
โ โโ Publishes to RubyGems.org
|
|
66
|
+
โ โโ Publishes to GitHub Packages
|
|
67
|
+
โ โโ Creates git tag (v0.3.1)
|
|
68
|
+
โ โโ Creates GitHub Release
|
|
69
|
+
โ
|
|
70
|
+
โโ> โ
pages.yml
|
|
71
|
+
โ โโ Deploys docs to GitHub Pages
|
|
72
|
+
โ
|
|
73
|
+
โโ> โ
security.yml
|
|
74
|
+
โโ Scans for vulnerabilities
|
|
75
|
+
|
|
76
|
+
Step 4: Done! Your gem is published ๐
|
|
77
|
+
โโ> Available at: https://rubygems.org/gems/pg_multitenant_schemas
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## ๐ Setup Checklist
|
|
83
|
+
|
|
84
|
+
### โ
**Already Done**
|
|
85
|
+
- [x] Created test.yml workflow
|
|
86
|
+
- [x] Created deploy.yml workflow
|
|
87
|
+
- [x] Created pages.yml workflow
|
|
88
|
+
- [x] Created security.yml workflow
|
|
89
|
+
- [x] Committed all workflows to git
|
|
90
|
+
|
|
91
|
+
### โณ **You Need to Do (5 minutes)**
|
|
92
|
+
|
|
93
|
+
**Step 1: Get RubyGems API Key**
|
|
94
|
+
```
|
|
95
|
+
1. Go to https://rubygems.org
|
|
96
|
+
2. Sign in with your account
|
|
97
|
+
3. Click on your profile โ Settings โ API Keys
|
|
98
|
+
4. Copy your existing API key (or create new one)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Step 2: Add Secret to GitHub**
|
|
102
|
+
```
|
|
103
|
+
1. Go to your repo: https://github.com/rubenpazch/pg_multitenant_schemas
|
|
104
|
+
2. Click: Settings โ Secrets and variables โ Actions
|
|
105
|
+
3. Click: New repository secret
|
|
106
|
+
4. Name: RUBYGEMS_API_KEY
|
|
107
|
+
5. Value: (paste the API key from step 1)
|
|
108
|
+
6. Click: Add secret
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Step 3: Enable GitHub Pages**
|
|
112
|
+
```
|
|
113
|
+
1. Same repo โ Settings โ Pages
|
|
114
|
+
2. Under "Build and deployment"
|
|
115
|
+
3. Source: Select "GitHub Actions"
|
|
116
|
+
4. Save
|
|
117
|
+
|
|
118
|
+
โ
Your docs will be at:
|
|
119
|
+
https://rubenpazch.github.io/pg_multitenant_schemas/
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Step 4: Push Latest Changes**
|
|
123
|
+
```bash
|
|
124
|
+
cd /Users/rubenpaz/personal/frontend/pg_multitenant_schemas
|
|
125
|
+
git push origin main
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## ๐ฏ Test It Out
|
|
131
|
+
|
|
132
|
+
### **Option A: Test with a dry run**
|
|
133
|
+
```bash
|
|
134
|
+
# 1. Create a test commit (no version change)
|
|
135
|
+
git commit --allow-empty -m "Test GitHub Actions"
|
|
136
|
+
git push origin main
|
|
137
|
+
|
|
138
|
+
# 2. Watch workflows run:
|
|
139
|
+
# https://github.com/rubenpazch/pg_multitenant_schemas/actions
|
|
140
|
+
|
|
141
|
+
# Expected: test.yml runs, deploy.yml skips (no version change)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### **Option B: Do a real release**
|
|
145
|
+
```bash
|
|
146
|
+
# 1. Update version
|
|
147
|
+
echo 'VERSION = "0.3.1"' > lib/pg_multitenant_schemas/version.rb
|
|
148
|
+
|
|
149
|
+
# 2. Update CHANGELOG.md with release notes
|
|
150
|
+
|
|
151
|
+
# 3. Push
|
|
152
|
+
git add -A
|
|
153
|
+
git commit -m "Bump version to 0.3.1"
|
|
154
|
+
git push origin main
|
|
155
|
+
|
|
156
|
+
# 4. Watch everything happen automatically ๐
|
|
157
|
+
# https://github.com/rubenpazch/pg_multitenant_schemas/actions
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## ๐ Workflow Triggers
|
|
163
|
+
|
|
164
|
+
| Workflow | Trigger | Action | Time |
|
|
165
|
+
|----------|---------|--------|------|
|
|
166
|
+
| **test.yml** | Push to main<br/>All PRs | Run 16 test suites | ~5 min |
|
|
167
|
+
| **deploy.yml** | version.rb change | Build + Publish | ~3 min |
|
|
168
|
+
| **pages.yml** | docs/ change | Deploy to Pages | ~2 min |
|
|
169
|
+
| **security.yml** | Weekly Sunday<br/>Push to main | Run scans | ~3 min |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## ๐ Security Notes
|
|
174
|
+
|
|
175
|
+
- โ
RUBYGEMS_API_KEY is encrypted in GitHub
|
|
176
|
+
- โ
Never shown in logs or public places
|
|
177
|
+
- โ
Only used during deploy step
|
|
178
|
+
- โ
Can be rotated anytime from https://rubygems.org
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## ๐ Learn More
|
|
183
|
+
|
|
184
|
+
**Full Setup Guide:** [`GITHUB_ACTIONS_SETUP.md`](./GITHUB_ACTIONS_SETUP.md)
|
|
185
|
+
- Complete step-by-step instructions
|
|
186
|
+
- Troubleshooting guide
|
|
187
|
+
- Branch protection setup
|
|
188
|
+
- Monitoring deployments
|
|
189
|
+
|
|
190
|
+
**Quick Reference:** [`GITHUB_ACTIONS_QUICK_START.md`](./GITHUB_ACTIONS_QUICK_START.md)
|
|
191
|
+
- One-page quick start
|
|
192
|
+
- Key commands
|
|
193
|
+
- Common issues
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## ๐ Quick Troubleshooting
|
|
198
|
+
|
|
199
|
+
**Deploy didn't run after push?**
|
|
200
|
+
โ Did you change `version.rb`? That's the only trigger.
|
|
201
|
+
|
|
202
|
+
**Tests are failing?**
|
|
203
|
+
โ Check Actions tab โ test.yml โ See detailed logs
|
|
204
|
+
|
|
205
|
+
**RubyGems publish failed?**
|
|
206
|
+
โ Is `RUBYGEMS_API_KEY` secret configured?
|
|
207
|
+
|
|
208
|
+
**GitHub Pages not showing?**
|
|
209
|
+
โ Is Pages source set to "GitHub Actions"? (Settings โ Pages)
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## โจ Next Steps
|
|
214
|
+
|
|
215
|
+
1. โ
Set RUBYGEMS_API_KEY (5 min)
|
|
216
|
+
2. โ
Enable GitHub Pages (2 min)
|
|
217
|
+
3. โ
Push to GitHub: `git push origin main`
|
|
218
|
+
4. โ
Watch Actions: https://github.com/rubenpazch/pg_multitenant_schemas/actions
|
|
219
|
+
5. โ
Test publish by bumping version
|
|
220
|
+
|
|
221
|
+
**That's it! Your gem now auto-deploys.** ๐
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## ๐ Questions?
|
|
226
|
+
|
|
227
|
+
See **GITHUB_ACTIONS_SETUP.md** for:
|
|
228
|
+
- Detailed workflow explanations
|
|
229
|
+
- Every step with screenshots
|
|
230
|
+
- Common issues and solutions
|
|
231
|
+
- Advanced configuration
|
data/LICENSE.txt
CHANGED
data/LOCAL_TESTING_SUMMARY.md
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
# ๐งช Summary: How to Test GitHub Workflows Locally
|
|
2
2
|
|
|
3
|
+
## ๐ฆ Current Environment
|
|
4
|
+
|
|
5
|
+
- **Ruby Version**: 3.4.3 (required: โฅ 3.0.0)
|
|
6
|
+
- **Rails Version**: 8.1.3 (updated April 2026)
|
|
7
|
+
- **RSpec**: 3.13.2 with rspec-rails 8.0.4
|
|
8
|
+
- **PostgreSQL**: 1.6.3 gem
|
|
9
|
+
- **RuboCop**: 1.86.1 (latest linter)
|
|
10
|
+
|
|
11
|
+
**โ
All 160 tests passing** with latest dependency versions
|
|
12
|
+
|
|
13
|
+
## ๐ Recent Dependency Updates (April 2026)
|
|
14
|
+
|
|
15
|
+
| Dependency | Previous | Current | Status |
|
|
16
|
+
|---|---|---|---|
|
|
17
|
+
| Rails (all gems) | 8.0.2.1 | 8.1.3 | โ
Updated |
|
|
18
|
+
| rspec-rails | 7.1.1 | 8.0.4 | โ
Updated |
|
|
19
|
+
| pg (PostgreSQL) | 1.6.2 | 1.6.3 | โ
Updated |
|
|
20
|
+
| rubocop | 1.80.1 | 1.86.1 | โ
Updated |
|
|
21
|
+
| rubocop-rspec_rails | 2.31.0 | 2.32.0 | โ
Updated |
|
|
22
|
+
| 40+ supporting gems | Various | Latest | โ
Updated |
|
|
23
|
+
|
|
24
|
+
**Test Results**: All 160 tests pass with upgraded dependencies. No breaking changes.
|
|
25
|
+
|
|
3
26
|
## โ
What You Can Do Right Now
|
|
4
27
|
|
|
5
|
-
### 1. **Pre-Push Script (Recommended)
|
|
28
|
+
### 1. **Pre-Push Script (Recommended)**
|
|
6
29
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **`TESTING_LOCALLY.md`** - Quick start guide
|
|
10
|
-
- **`docs/local_workflow_testing.md`** - Complete documentation
|
|
11
|
-
- **`.actrc`** - act configuration
|
|
12
|
-
- **`.env.local.example`** - Environment templateh
|
|
13
|
-
# Run this before every push
|
|
30
|
+
Run this before every push:
|
|
31
|
+
```bash
|
|
14
32
|
./pre-push-check.sh
|
|
15
33
|
```
|
|
16
34
|
This validates everything that runs in CI:
|
|
@@ -21,18 +39,17 @@ This validates everything that runs in CI:
|
|
|
21
39
|
- โ
Integration tests (if PostgreSQL available)
|
|
22
40
|
|
|
23
41
|
### 2. **Manual Component Testing**
|
|
24
|
-
|
|
42
|
+
|
|
25
43
|
```bash
|
|
26
44
|
# Test each CI component individually
|
|
27
45
|
bundle install
|
|
28
46
|
bundle exec rubocop # Code style check
|
|
29
|
-
bundle exec rspec # Run all tests
|
|
47
|
+
bundle exec rspec # Run all tests (160 tests)
|
|
30
48
|
bundle exec rspec --tag integration # Integration tests only
|
|
31
49
|
bundle exec rspec --exclude-pattern '**/integration/**/*_spec.rb' # Unit tests only
|
|
32
50
|
bundle audit # Security audit
|
|
33
51
|
gem build pg_multitenant_schemas.gemspec # Test gem build
|
|
34
52
|
```
|
|
35
|
-
```
|
|
36
53
|
|
|
37
54
|
### 3. **act Tool (Partial Support)**
|
|
38
55
|
```bash
|
|
@@ -114,8 +131,8 @@ createdb pg_multitenant_test
|
|
|
114
131
|
### Ruby Issues
|
|
115
132
|
```bash
|
|
116
133
|
# Install correct Ruby version
|
|
117
|
-
rbenv install 3.3
|
|
118
|
-
rbenv local 3.3
|
|
134
|
+
rbenv install 3.4.3
|
|
135
|
+
rbenv local 3.4.3
|
|
119
136
|
bundle install
|
|
120
137
|
```
|
|
121
138
|
|
data/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
[](https://badge.fury.io/rb/pg_multitenant_schemas)
|
|
4
4
|
[](https://github.com/yourusername/pg_multitenant_schemas/actions/workflows/main.yml)
|
|
5
5
|
|
|
6
|
-
A modern Ruby gem that provides PostgreSQL schema-based multitenancy with automatic tenant resolution and schema switching.
|
|
6
|
+
A modern Ruby gem that provides PostgreSQL schema-based multitenancy with automatic tenant resolution and schema switching. Compatible with Rails 7+ and Ruby 3.0+, with optimizations for Rails 8, focusing on security, performance, and developer experience.
|
|
7
7
|
|
|
8
8
|
## โจ Features
|
|
9
9
|
|
|
10
10
|
- ๐ข **Schema-based multitenancy** - Complete tenant isolation using PostgreSQL schemas
|
|
11
11
|
- ๐ **Automatic schema switching** - Seamlessly switch between tenant schemas
|
|
12
12
|
- ๐ **Subdomain resolution** - Extract tenant from request subdomains
|
|
13
|
-
-
|
|
13
|
+
- ๐ **Rails 7+ compatible** - Works with Rails 7 and optimized for Rails 8
|
|
14
14
|
- ๏ฟฝ๏ธ **Security-first design** - Database-level tenant isolation
|
|
15
15
|
- ๐งต **Thread-safe** - Safe for concurrent operations
|
|
16
16
|
- ๐ **Comprehensive logging** - Track schema operations
|
|
@@ -20,8 +20,8 @@ A modern Ruby gem that provides PostgreSQL schema-based multitenancy with automa
|
|
|
20
20
|
|
|
21
21
|
## Requirements
|
|
22
22
|
|
|
23
|
-
- Ruby 3.
|
|
24
|
-
- Rails
|
|
23
|
+
- Ruby 3.0+
|
|
24
|
+
- Rails 7.0+
|
|
25
25
|
- PostgreSQL 12+
|
|
26
26
|
- **pg gem**: 1.5 or higher
|
|
27
27
|
|