pg_multitenant_schemas 0.2.0 โ 0.2.3
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/.actrc +17 -0
- data/.env.local.example +21 -0
- data/CHANGELOG.md +39 -1
- data/LOCAL_TESTING_SUMMARY.md +141 -0
- data/README.md +4 -4
- data/TESTING_LOCALLY.md +208 -0
- data/docs/README.md +4 -0
- data/docs/github_actions_permissions_fix.md +136 -0
- data/docs/github_actions_setup.md +181 -0
- data/docs/local_workflow_testing.md +314 -0
- data/docs/testing_rails_tasks.md +128 -0
- 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/railtie.rb +4 -1
- data/lib/pg_multitenant_schemas/schema_switcher.rb +34 -0
- data/lib/pg_multitenant_schemas/tasks/tenant_tasks.rake +0 -3
- data/lib/pg_multitenant_schemas/version.rb +1 -1
- data/pg_multitenant_schemas.gemspec +5 -5
- data/pre-push-check.sh +95 -0
- data/test-github-setup.sh +85 -0
- data/validate-github-commands.sh +47 -0
- metadata +20 -10
- data/lib/pg_multitenant_schemas/tasks/pg_multitenant_schemas.rake +0 -65
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f362436f339eb06d63f3c54a928054b0dd454eb0c6165f219d57ad1658476b50
|
|
4
|
+
data.tar.gz: 150c105745e09f419168145f57a70c856241fea231cf20d87d01d8cce1da60a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 228d2da53051f03e48dd828eec5817987b4029c850026a58493cec6a7877a126cf5b632722bcc5607c686b704e87555bfad583d364895a314182317f6ce0f9c8
|
|
7
|
+
data.tar.gz: c891689fabcd8b3ee54752f9dc3a7bd54c37eabf9a081a4696f23ec0bb01cf0439a98899c8a51ba90661ca92929719f3fd1c3e63d63b54b8b9a56393f418fc4e
|
data/.actrc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# act configuration file
|
|
2
|
+
# This configures act to run GitHub Actions locally
|
|
3
|
+
|
|
4
|
+
# Use Linux AMD64 architecture for compatibility
|
|
5
|
+
--container-architecture linux/amd64
|
|
6
|
+
|
|
7
|
+
# Set artifact server path
|
|
8
|
+
--artifact-server-path /tmp/act-artifacts
|
|
9
|
+
|
|
10
|
+
# Load environment variables from local file
|
|
11
|
+
--env-file .env.local
|
|
12
|
+
|
|
13
|
+
# Use medium size runner image
|
|
14
|
+
--platform ubuntu-latest=catthehacker/ubuntu:act-latest
|
|
15
|
+
|
|
16
|
+
# Show more verbose output
|
|
17
|
+
--verbose
|
data/.env.local.example
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Local environment variables for testing with act
|
|
2
|
+
# Copy this to .env.local and fill in your actual values
|
|
3
|
+
|
|
4
|
+
# GitHub token (create at https://github.com/settings/tokens)
|
|
5
|
+
# Needs repo and workflow permissions
|
|
6
|
+
GITHUB_TOKEN=your_github_token_here
|
|
7
|
+
|
|
8
|
+
# RubyGems API key (get from https://rubygems.org/profile/edit)
|
|
9
|
+
# Only needed for testing release workflow
|
|
10
|
+
RUBYGEMS_API_KEY=your_rubygems_api_key_here
|
|
11
|
+
|
|
12
|
+
# Repository information
|
|
13
|
+
GITHUB_REPOSITORY=rubenpazch/pg_multitenant_schemas
|
|
14
|
+
GITHUB_ACTOR=your_github_username
|
|
15
|
+
|
|
16
|
+
# PostgreSQL configuration for local testing
|
|
17
|
+
PGDATABASE=pg_multitenant_test
|
|
18
|
+
PGUSER=postgres
|
|
19
|
+
PGPASSWORD=
|
|
20
|
+
PGHOST=localhost
|
|
21
|
+
PGPORT=5432
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,39 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.2.3] - 2025-01-17
|
|
9
|
+
|
|
10
|
+
### ๐ง **Developer Experience & Testing**
|
|
11
|
+
- **NEW: Local Workflow Testing**: Complete solution for testing GitHub Actions locally before push
|
|
12
|
+
- **NEW: Pre-Push Validation**: `pre-push-check.sh` script validates CI components locally
|
|
13
|
+
- **NEW: GitHub Actions Testing**: `act` tool integration with configuration files
|
|
14
|
+
- **NEW: Validation Scripts**: `validate-github-commands.sh` and `test-github-setup.sh`
|
|
15
|
+
|
|
16
|
+
### ๐ **CI/CD Improvements**
|
|
17
|
+
- **FIXED: GitHub Actions Permissions**: Resolved permission issues with release workflow
|
|
18
|
+
- **FIXED: RSpec Command**: Corrected `--exclude-pattern` usage for unit test isolation
|
|
19
|
+
- **IMPROVED: Release Automation**: Enhanced release workflow with proper bot identity
|
|
20
|
+
- **IMPROVED: Documentation**: Comprehensive guides for CI/CD setup and troubleshooting
|
|
21
|
+
|
|
22
|
+
### ๐ **Documentation Enhancements**
|
|
23
|
+
- **NEW: Local Testing Guide**: `TESTING_LOCALLY.md` and `LOCAL_TESTING_SUMMARY.md`
|
|
24
|
+
- **NEW: CI/CD Setup Guide**: `docs/github_actions_setup.md` with step-by-step instructions
|
|
25
|
+
- **NEW: Permissions Fix Guide**: `docs/github_actions_permissions_fix.md`
|
|
26
|
+
- **NEW: Workflow Testing Guide**: `docs/local_workflow_testing.md`
|
|
27
|
+
- **IMPROVED: Core Documentation**: Updated `docs/README.md` with local testing references
|
|
28
|
+
|
|
29
|
+
### ๐งช **Testing Infrastructure**
|
|
30
|
+
- **ENHANCED: RuboCop Compliance**: Fixed all code style violations across test suite
|
|
31
|
+
- **ENHANCED: Test Organization**: Improved test structure and mocking patterns
|
|
32
|
+
- **ENHANCED: Integration Testing**: Better PostgreSQL integration test support
|
|
33
|
+
- **ENHANCED: Security Auditing**: Bundle audit integration in CI pipeline
|
|
34
|
+
|
|
35
|
+
### ๐ง **Configuration Files**
|
|
36
|
+
- **NEW: `.actrc`**: Configuration for local GitHub Actions testing
|
|
37
|
+
- **NEW: `.env.local.example`**: Template for local environment variables
|
|
38
|
+
- **IMPROVED: `.gitignore`**: Added local testing files to ignore list
|
|
39
|
+
|
|
40
|
+
## [0.2.1] - 2025-09-06
|
|
9
41
|
|
|
10
42
|
### ๐ **Migration System Overhaul**
|
|
11
43
|
- **NEW: Automated Migration Management**: Complete migration system for multi-tenant schemas
|
|
@@ -94,3 +126,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
94
126
|
- Initial release
|
|
95
127
|
- Basic schema switching functionality
|
|
96
128
|
- PostgreSQL multitenancy support
|
|
129
|
+
|
|
130
|
+
[Unreleased]: https://github.com/rubenpazch/pg_multitenant_schemas/compare/v0.2.2...HEAD
|
|
131
|
+
[0.2.2]: https://github.com/rubenpazch/pg_multitenant_schemas/compare/v0.2.1...v0.2.2
|
|
132
|
+
[0.2.1]: https://github.com/rubenpazch/pg_multitenant_schemas/compare/v0.2.0...v0.2.1
|
|
133
|
+
[0.2.0]: https://github.com/rubenpazch/pg_multitenant_schemas/compare/v0.1.0...v0.2.0
|
|
134
|
+
[0.1.0]: https://github.com/rubenpazch/pg_multitenant_schemas/releases/tag/v0.1.0
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# ๐งช Summary: How to Test GitHub Workflows Locally
|
|
2
|
+
|
|
3
|
+
## โ
What You Can Do Right Now
|
|
4
|
+
|
|
5
|
+
### 1. **Pre-Push Script (Recommended)**## ๐ **Files Created**
|
|
6
|
+
|
|
7
|
+
- **`pre-push-check.sh`** - Main testing script
|
|
8
|
+
- **`validate-github-commands.sh`** - Test exact GitHub Actions commands
|
|
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
|
|
14
|
+
./pre-push-check.sh
|
|
15
|
+
```
|
|
16
|
+
This validates everything that runs in CI:
|
|
17
|
+
- โ
RuboCop (code style)
|
|
18
|
+
- โ
RSpec (tests)
|
|
19
|
+
- โ
Bundle audit (security)
|
|
20
|
+
- โ
Gem building
|
|
21
|
+
- โ
Integration tests (if PostgreSQL available)
|
|
22
|
+
|
|
23
|
+
### 2. **Manual Component Testing**
|
|
24
|
+
```bash
|
|
25
|
+
```bash
|
|
26
|
+
# Test each CI component individually
|
|
27
|
+
bundle install
|
|
28
|
+
bundle exec rubocop # Code style check
|
|
29
|
+
bundle exec rspec # Run all tests
|
|
30
|
+
bundle exec rspec --tag integration # Integration tests only
|
|
31
|
+
bundle exec rspec --exclude-pattern '**/integration/**/*_spec.rb' # Unit tests only
|
|
32
|
+
bundle audit # Security audit
|
|
33
|
+
gem build pg_multitenant_schemas.gemspec # Test gem build
|
|
34
|
+
```
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 3. **act Tool (Partial Support)**
|
|
38
|
+
```bash
|
|
39
|
+
# List workflows
|
|
40
|
+
act -l
|
|
41
|
+
|
|
42
|
+
# Dry run (shows what would execute)
|
|
43
|
+
act -n push
|
|
44
|
+
|
|
45
|
+
# Note: Currently has issues with PostgreSQL services
|
|
46
|
+
# Better for simple workflows without database dependencies
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## ๐ฏ **Before Every Push Checklist**
|
|
50
|
+
|
|
51
|
+
1. โ
Run `./pre-push-check.sh`
|
|
52
|
+
2. โ
Fix any issues found
|
|
53
|
+
3. โ
Commit your changes
|
|
54
|
+
4. โ
Push to GitHub
|
|
55
|
+
|
|
56
|
+
## ๐ **Component Status**
|
|
57
|
+
|
|
58
|
+
| Component | Local Testing | Status |
|
|
59
|
+
|-----------|---------------|---------|
|
|
60
|
+
| RuboCop | โ
`bundle exec rubocop` | Working |
|
|
61
|
+
| Unit Tests | โ
`bundle exec rspec` | Working |
|
|
62
|
+
| Integration Tests | โ
With local PostgreSQL | Working |
|
|
63
|
+
| Security Audit | โ
`bundle audit` | Working |
|
|
64
|
+
| Gem Building | โ
`gem build *.gemspec` | Working |
|
|
65
|
+
| Release Workflow | โ ๏ธ Manual simulation only | Partial |
|
|
66
|
+
| Full CI with act | โ ๏ธ PostgreSQL service issues | Limited |
|
|
67
|
+
|
|
68
|
+
## ๐ง **Quick Setup**
|
|
69
|
+
|
|
70
|
+
1. **Make pre-push script executable:**
|
|
71
|
+
```bash
|
|
72
|
+
chmod +x pre-push-check.sh
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. **Install act (optional):**
|
|
76
|
+
```bash
|
|
77
|
+
brew install act
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
3. **Create environment file (for act):**
|
|
81
|
+
```bash
|
|
82
|
+
cp .env.local.example .env.local
|
|
83
|
+
# Edit .env.local with your tokens if needed
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## ๐ **Recommended Workflow**
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Make your changes
|
|
90
|
+
git add .
|
|
91
|
+
|
|
92
|
+
# 2. Test locally
|
|
93
|
+
./pre-push-check.sh
|
|
94
|
+
|
|
95
|
+
# 3. If all passes, commit and push
|
|
96
|
+
git commit -m "Your changes"
|
|
97
|
+
git push
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## ๐ ๏ธ **Troubleshooting**
|
|
101
|
+
|
|
102
|
+
### PostgreSQL Issues
|
|
103
|
+
```bash
|
|
104
|
+
# Check if PostgreSQL is running
|
|
105
|
+
pg_isready
|
|
106
|
+
|
|
107
|
+
# Start PostgreSQL (macOS)
|
|
108
|
+
brew services start postgresql@15
|
|
109
|
+
|
|
110
|
+
# Create test database
|
|
111
|
+
createdb pg_multitenant_test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Ruby Issues
|
|
115
|
+
```bash
|
|
116
|
+
# Install correct Ruby version
|
|
117
|
+
rbenv install 3.3.0
|
|
118
|
+
rbenv local 3.3.0
|
|
119
|
+
bundle install
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### act Issues
|
|
123
|
+
```bash
|
|
124
|
+
# Try without services (simpler)
|
|
125
|
+
act -j security # Just run security audit job
|
|
126
|
+
|
|
127
|
+
# Check Docker is running
|
|
128
|
+
docker ps
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## ๐ **Files Created**
|
|
132
|
+
|
|
133
|
+
- **`pre-push-check.sh`** - Main testing script
|
|
134
|
+
- **`TESTING_LOCALLY.md`** - Quick start guide
|
|
135
|
+
- **`docs/local_workflow_testing.md`** - Complete documentation
|
|
136
|
+
- **`.actrc`** - act configuration
|
|
137
|
+
- **`.env.local.example`** - Environment template
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
**๐ก Bottom Line**: Use `./pre-push-check.sh` for reliable local testing. It covers 95% of what CI does and catches issues early!
|
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
|
|
data/TESTING_LOCALLY.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ๐ Quick Start: Testing GitHub Workflows Locally
|
|
2
|
+
|
|
3
|
+
This guide gets you up and running quickly with local GitHub Actions testing.
|
|
4
|
+
|
|
5
|
+
## ๐ฏ TL;DR - Quick Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Run pre-push checks (recommended before every push)
|
|
9
|
+
./pre-push-check.sh
|
|
10
|
+
|
|
11
|
+
# 2. Test GitHub Actions locally with act
|
|
12
|
+
act -l # List all workflows
|
|
13
|
+
act push # Test CI workflow
|
|
14
|
+
act pull_request # Test PR workflow
|
|
15
|
+
|
|
16
|
+
# 3. Manual component testing
|
|
17
|
+
bundle exec rubocop # Code style check
|
|
18
|
+
bundle exec rspec # Run tests
|
|
19
|
+
gem build *.gemspec # Test gem building
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## ๐ง One-Time Setup
|
|
23
|
+
|
|
24
|
+
### 1. Install act (if not already installed)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# macOS
|
|
28
|
+
brew install act
|
|
29
|
+
|
|
30
|
+
# Linux
|
|
31
|
+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
|
|
32
|
+
|
|
33
|
+
# Windows
|
|
34
|
+
choco install act-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Create local environment file
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Copy the example and fill in your values
|
|
41
|
+
cp .env.local.example .env.local
|
|
42
|
+
|
|
43
|
+
# Edit with your actual tokens (optional, only needed for release testing)
|
|
44
|
+
nano .env.local
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## ๐งช Testing Strategies
|
|
48
|
+
|
|
49
|
+
### Strategy 1: Pre-Push Script (Recommended)
|
|
50
|
+
|
|
51
|
+
Run this before every push:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
./pre-push-check.sh
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This runs:
|
|
58
|
+
- โ
RuboCop (code style)
|
|
59
|
+
- โ
RSpec (unit tests)
|
|
60
|
+
- โ
Security audit
|
|
61
|
+
- โ
Gem build test
|
|
62
|
+
- โ
Integration tests (if PostgreSQL available)
|
|
63
|
+
|
|
64
|
+
### Strategy 2: act - GitHub Actions Locally
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Test the main CI workflow
|
|
68
|
+
act push
|
|
69
|
+
|
|
70
|
+
# Test pull request workflow
|
|
71
|
+
act pull_request
|
|
72
|
+
|
|
73
|
+
# Dry run (see what would execute)
|
|
74
|
+
act -n
|
|
75
|
+
|
|
76
|
+
# Test specific job
|
|
77
|
+
act -j test
|
|
78
|
+
|
|
79
|
+
# List all available workflows and jobs
|
|
80
|
+
act -l
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Strategy 3: Manual Component Testing
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Test each component individually
|
|
87
|
+
bundle install
|
|
88
|
+
bundle exec rubocop
|
|
89
|
+
bundle exec rspec
|
|
90
|
+
bundle exec rspec --exclude-pattern '**/integration/**/*_spec.rb' # Unit tests only
|
|
91
|
+
bundle exec rspec --tag integration # Integration tests only
|
|
92
|
+
bundle audit
|
|
93
|
+
gem build pg_multitenant_schemas.gemspec
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐ฏ Workflow-Specific Testing
|
|
97
|
+
|
|
98
|
+
### Testing CI Workflow (.github/workflows/main.yml)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# With act
|
|
102
|
+
act push
|
|
103
|
+
|
|
104
|
+
# Manual simulation
|
|
105
|
+
bundle install
|
|
106
|
+
bundle exec rubocop
|
|
107
|
+
bundle exec rspec --exclude-pattern '**/integration/**/*_spec.rb'
|
|
108
|
+
bundle audit
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Testing Release Workflow (.github/workflows/release.yml)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# With act (simulates main branch push)
|
|
115
|
+
act push --env GITHUB_REF=refs/heads/main
|
|
116
|
+
|
|
117
|
+
# Manual simulation (WITHOUT publishing)
|
|
118
|
+
# 1. Update version in lib/pg_multitenant_schemas/version.rb
|
|
119
|
+
# 2. Build gem locally
|
|
120
|
+
gem build pg_multitenant_schemas.gemspec
|
|
121
|
+
# 3. Check gem contents
|
|
122
|
+
gem contents pg_multitenant_schemas-*.gem
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## ๐ Troubleshooting
|
|
126
|
+
|
|
127
|
+
### act Issues
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Docker not running
|
|
131
|
+
# โ Start Docker Desktop
|
|
132
|
+
|
|
133
|
+
# Permission denied
|
|
134
|
+
# โ Fix Docker permissions or use sudo
|
|
135
|
+
|
|
136
|
+
# Platform issues
|
|
137
|
+
act --container-architecture linux/amd64
|
|
138
|
+
|
|
139
|
+
# Secrets not found
|
|
140
|
+
# โ Check .env.local file exists and has correct values
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### PostgreSQL Issues
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Check if PostgreSQL is running
|
|
147
|
+
pg_isready
|
|
148
|
+
|
|
149
|
+
# Start PostgreSQL (macOS)
|
|
150
|
+
brew services start postgresql@15
|
|
151
|
+
|
|
152
|
+
# Create test database
|
|
153
|
+
createdb pg_multitenant_test
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Ruby/Bundle Issues
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Install correct Ruby version
|
|
160
|
+
rbenv install 3.3.0
|
|
161
|
+
rbenv local 3.3.0
|
|
162
|
+
|
|
163
|
+
# Clean and reinstall gems
|
|
164
|
+
bundle clean --force
|
|
165
|
+
bundle install
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## ๐ Typical Workflow
|
|
169
|
+
|
|
170
|
+
1. **Make changes** to your code
|
|
171
|
+
2. **Run pre-push checks**: `./pre-push-check.sh`
|
|
172
|
+
3. **Fix any issues** found
|
|
173
|
+
4. **Test with act** (optional): `act push`
|
|
174
|
+
5. **Commit and push** when everything passes
|
|
175
|
+
|
|
176
|
+
## ๐ Integration with Git
|
|
177
|
+
|
|
178
|
+
Add to `.git/hooks/pre-push` to run checks automatically:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
#!/bin/bash
|
|
182
|
+
./pre-push-check.sh
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Make it executable:
|
|
186
|
+
```bash
|
|
187
|
+
chmod +x .git/hooks/pre-push
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## ๐ Success Indicators
|
|
191
|
+
|
|
192
|
+
You're ready to push when you see:
|
|
193
|
+
|
|
194
|
+
- โ
Pre-push script passes all checks
|
|
195
|
+
- โ
`act push` completes without errors
|
|
196
|
+
- โ
All tests pass locally
|
|
197
|
+
- โ
RuboCop shows no violations
|
|
198
|
+
- โ
Gem builds successfully
|
|
199
|
+
|
|
200
|
+
## ๐ More Information
|
|
201
|
+
|
|
202
|
+
- [Complete Guide](docs/local_workflow_testing.md) - Detailed documentation
|
|
203
|
+
- [GitHub Actions Docs](https://docs.github.com/en/actions)
|
|
204
|
+
- [act Documentation](https://github.com/nektos/act)
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
**๐ก Pro Tip**: Run `./pre-push-check.sh` before every commit to catch issues early!
|
data/docs/README.md
CHANGED
|
@@ -15,6 +15,8 @@ This directory contains detailed documentation for each core component of the PG
|
|
|
15
15
|
| **Errors** | Custom exception classes | [errors.md](errors.md) |
|
|
16
16
|
| **Testing** | RSpec test suite and testing guide | [testing.md](testing.md) |
|
|
17
17
|
| **Integration Testing** | PostgreSQL integration testing guide | [integration_testing.md](integration_testing.md) |
|
|
18
|
+
| **CI/CD & Releases** | GitHub Actions automation setup | [github_actions_setup.md](github_actions_setup.md) |
|
|
19
|
+
| **Local Workflow Testing** | Test GitHub Actions locally before push | [local_workflow_testing.md](local_workflow_testing.md) |
|
|
18
20
|
|
|
19
21
|
## ๐๏ธ Architecture Flow
|
|
20
22
|
|
|
@@ -60,7 +62,9 @@ Rails Application (executes in tenant schema)
|
|
|
60
62
|
|
|
61
63
|
- **[Testing Guide](testing.md)**: Comprehensive RSpec test suite documentation
|
|
62
64
|
- **[Integration Testing](integration_testing.md)**: PostgreSQL integration testing guide
|
|
65
|
+
- **[Local Workflow Testing](local_workflow_testing.md)**: Test GitHub Actions locally before push
|
|
63
66
|
- **Test Execution**: `bundle exec rspec` (unit tests) and `bundle exec rspec --tag integration` (integration tests)
|
|
67
|
+
- **Pre-Push Testing**: `./pre-push-check.sh` (validates CI components locally)
|
|
64
68
|
|
|
65
69
|
## ๐ Debug and Troubleshooting
|
|
66
70
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# ๐ง Fixing GitHub Actions Permissions Issues
|
|
2
|
+
|
|
3
|
+
## ๐จ Problem
|
|
4
|
+
```
|
|
5
|
+
remote: Permission to rubenpazch/pg_multitenant_schemas.git denied to github-actions[bot].
|
|
6
|
+
fatal: unable to access 'https://github.com/rubenpazch/pg_multitenant_schemas/': The requested URL returned error: 403
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## โ
Solutions Applied
|
|
10
|
+
|
|
11
|
+
### 1. Updated Release Workflow Permissions
|
|
12
|
+
Added explicit permissions to `.github/workflows/release.yml`:
|
|
13
|
+
```yaml
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write
|
|
16
|
+
issues: write
|
|
17
|
+
pull-requests: write
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Fixed GitHub Actions Bot Identity
|
|
21
|
+
Changed Git configuration to use proper GitHub Actions bot identity:
|
|
22
|
+
```yaml
|
|
23
|
+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
24
|
+
git config --local user.name "github-actions[bot]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## ๐ง Repository Settings to Check
|
|
28
|
+
|
|
29
|
+
### On GitHub.com:
|
|
30
|
+
|
|
31
|
+
1. **Go to your repository settings**
|
|
32
|
+
- Navigate to: `https://github.com/rubenpazch/pg_multitenant_schemas/settings`
|
|
33
|
+
|
|
34
|
+
2. **Actions > General**
|
|
35
|
+
- Scroll down to "Workflow permissions"
|
|
36
|
+
- Select: **"Read and write permissions"**
|
|
37
|
+
- Check: **"Allow GitHub Actions to create and approve pull requests"**
|
|
38
|
+
- Click **Save**
|
|
39
|
+
|
|
40
|
+
3. **Actions > General > Actions permissions**
|
|
41
|
+
- Ensure: **"Allow all actions and reusable workflows"** is selected
|
|
42
|
+
- Or at least: **"Allow actions created by GitHub"**
|
|
43
|
+
|
|
44
|
+
## ๐งช Alternative Testing Approach
|
|
45
|
+
|
|
46
|
+
If you want to test the release workflow without actual releases:
|
|
47
|
+
|
|
48
|
+
### Create a Test Branch Release Workflow
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
# .github/workflows/test-release.yml
|
|
52
|
+
name: Test Release Workflow
|
|
53
|
+
|
|
54
|
+
on:
|
|
55
|
+
workflow_dispatch: # Manual trigger only
|
|
56
|
+
|
|
57
|
+
permissions:
|
|
58
|
+
contents: write
|
|
59
|
+
issues: write
|
|
60
|
+
pull-requests: write
|
|
61
|
+
|
|
62
|
+
jobs:
|
|
63
|
+
test-release:
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
|
|
66
|
+
steps:
|
|
67
|
+
- name: Checkout code
|
|
68
|
+
uses: actions/checkout@v4
|
|
69
|
+
with:
|
|
70
|
+
fetch-depth: 0
|
|
71
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
72
|
+
|
|
73
|
+
- name: Test Git config
|
|
74
|
+
run: |
|
|
75
|
+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
76
|
+
git config --local user.name "github-actions[bot]"
|
|
77
|
+
echo "Git config successful"
|
|
78
|
+
|
|
79
|
+
- name: Test Git operations (dry run)
|
|
80
|
+
run: |
|
|
81
|
+
echo "Would create tag: v0.2.1"
|
|
82
|
+
echo "Would push to origin"
|
|
83
|
+
# Don't actually push in test
|
|
84
|
+
|
|
85
|
+
- name: Test gem build
|
|
86
|
+
run: |
|
|
87
|
+
gem build pg_multitenant_schemas.gemspec
|
|
88
|
+
ls -la *.gem
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## ๐ Troubleshooting Steps
|
|
92
|
+
|
|
93
|
+
### 1. Check Token Permissions
|
|
94
|
+
```bash
|
|
95
|
+
# In GitHub Actions, this should show the permissions
|
|
96
|
+
echo "GITHUB_TOKEN permissions:"
|
|
97
|
+
echo "Contents: ${{ github.token }}"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 2. Verify Repository Access
|
|
101
|
+
```bash
|
|
102
|
+
# Test if the bot can access the repo
|
|
103
|
+
git ls-remote origin
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 3. Check Branch Protection Rules
|
|
107
|
+
- Go to Settings > Branches
|
|
108
|
+
- Check if `main` branch has protection rules that block force pushes
|
|
109
|
+
- Ensure "Restrict pushes that create files" is not enabled
|
|
110
|
+
|
|
111
|
+
## ๐ฏ Quick Fix Summary
|
|
112
|
+
|
|
113
|
+
1. **โ
Updated workflow permissions** (already done)
|
|
114
|
+
2. **โ
Fixed bot identity** (already done)
|
|
115
|
+
3. **๐ง Check repository settings** (manual step on GitHub.com)
|
|
116
|
+
4. **๐งช Test with manual trigger** (if needed)
|
|
117
|
+
|
|
118
|
+
## ๐ Manual Steps Required
|
|
119
|
+
|
|
120
|
+
1. Go to your repository on GitHub.com
|
|
121
|
+
2. Navigate to Settings > Actions > General
|
|
122
|
+
3. Set "Workflow permissions" to "Read and write permissions"
|
|
123
|
+
4. Enable "Allow GitHub Actions to create and approve pull requests"
|
|
124
|
+
5. Save the settings
|
|
125
|
+
|
|
126
|
+
After making these changes, the release workflow should work properly!
|
|
127
|
+
|
|
128
|
+
## ๐ Testing the Fix
|
|
129
|
+
|
|
130
|
+
After updating repository settings, you can test by:
|
|
131
|
+
|
|
132
|
+
1. **Making a small version bump**
|
|
133
|
+
2. **Pushing to main branch**
|
|
134
|
+
3. **Watching the Actions tab** for successful execution
|
|
135
|
+
|
|
136
|
+
Or create the test workflow above and trigger it manually first.
|