@artik0din/turbogha 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright GitHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,322 @@
1
+ # TurboGHA
2
+
3
+ > Supercharge your Turborepo builds with free, self-hosted remote caching on GitHub Actions
4
+
5
+ [![CI](https://github.com/globodai-group/caching-for-turbo/actions/workflows/ci.yml/badge.svg)](https://github.com/globodai-group/caching-for-turbo/actions/workflows/ci.yml)
6
+ [![npm](https://img.shields.io/npm/v/@artik0din/turbogha)](https://www.npmjs.com/package/@artik0din/turbogha)
7
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8
+ [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org)
9
+
10
+ ## Why TurboGHA?
11
+
12
+ [Turborepo](https://turbo.build/repo/) is amazing for monorepo builds, but remote caching typically requires a Vercel account. **TurboGHA** provides a free, self-hosted alternative that runs entirely within GitHub's ecosystem.
13
+
14
+ | | TurboGHA | Vercel Remote Cache |
15
+ |---|:---:|:---:|
16
+ | **Cost** | Free | Paid (large teams) |
17
+ | **Setup** | 1 line | Account + tokens |
18
+ | **Storage** | GitHub Cache / S3 | Vercel only |
19
+ | **Control** | Full | Limited |
20
+ | **Dependencies** | None | Vercel account |
21
+
22
+ ## Quick Start
23
+
24
+ Add this step **before** your `turbo` commands:
25
+
26
+ ```yaml
27
+ - name: Setup Turbo Cache
28
+ uses: globodai-group/caching-for-turbo@v1
29
+
30
+ - name: Build
31
+ run: turbo build
32
+ ```
33
+
34
+ That's it! Your builds now use GitHub's built-in cache system.
35
+
36
+ ## How It Works
37
+
38
+ ```
39
+ ┌─────────────────────────────────────────────────────────────┐
40
+ │ GitHub Actions Runner │
41
+ ├─────────────────────────────────────────────────────────────┤
42
+ │ │
43
+ │ ┌─────────┐ HTTP ┌──────────────┐ │
44
+ │ │ Turbo │ ──────────► │ TurboGHA │ │
45
+ │ │ Build │ ◄────────── │ Server │ │
46
+ │ └─────────┘ │ :41230 │ │
47
+ │ └──────┬───────┘ │
48
+ │ │ │
49
+ │ ▼ │
50
+ │ ┌────────────────────────┐ │
51
+ │ │ Storage Backend │ │
52
+ │ │ ┌─────────┐ ┌─────┐ │ │
53
+ │ │ │ GitHub │ │ S3 │ │ │
54
+ │ │ │ Cache │ │ │ │ │
55
+ │ │ └─────────┘ └─────┘ │ │
56
+ │ └────────────────────────┘ │
57
+ └─────────────────────────────────────────────────────────────┘
58
+ ```
59
+
60
+ 1. **Setup Phase**: Starts a local Fastify server on `localhost:41230`
61
+ 2. **Environment**: Configures `TURBO_API`, `TURBO_TOKEN`, `TURBO_TEAM`
62
+ 3. **Caching**: Intercepts Turbo cache requests and stores in GitHub Cache or S3
63
+ 4. **Cleanup**: Gracefully shuts down and displays statistics
64
+
65
+ ## Configuration
66
+
67
+ ### Basic Usage
68
+
69
+ ```yaml
70
+ - uses: globodai-group/caching-for-turbo@v1
71
+ ```
72
+
73
+ ### With Options
74
+
75
+ ```yaml
76
+ - uses: globodai-group/caching-for-turbo@v1
77
+ with:
78
+ # Storage backend: 'github' (default) or 's3'
79
+ provider: github
80
+
81
+ # Cache key prefix (useful for cache isolation)
82
+ cache-prefix: my-project_
83
+
84
+ # Server port
85
+ server-port: 41230
86
+ ```
87
+
88
+ ### Cache Management
89
+
90
+ Prevent unbounded cache growth:
91
+
92
+ ```yaml
93
+ - uses: globodai-group/caching-for-turbo@v1
94
+ with:
95
+ # Remove entries older than duration
96
+ max-age: 2w # Supports: 1d, 1w, 1mo
97
+
98
+ # Keep only N most recent entries
99
+ max-files: 300
100
+
101
+ # Remove oldest when size exceeds limit
102
+ max-size: 5gb # Supports: 100mb, 1gb, 10gb
103
+ ```
104
+
105
+ ### S3 Storage
106
+
107
+ For teams needing dedicated infrastructure:
108
+
109
+ ```yaml
110
+ - uses: globodai-group/caching-for-turbo@v1
111
+ with:
112
+ provider: s3
113
+ s3-bucket: my-turbo-cache
114
+ s3-region: us-east-1
115
+ s3-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
116
+ s3-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
117
+
118
+ # Optional
119
+ s3-endpoint: https://s3.amazonaws.com
120
+ s3-prefix: cache/
121
+ s3-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
122
+ ```
123
+
124
+ **Compatible with**: AWS S3, MinIO, DigitalOcean Spaces, Cloudflare R2, Backblaze B2
125
+
126
+ ## CLI for Local Development
127
+
128
+ Use the same caching infrastructure locally:
129
+
130
+ ### Installation
131
+
132
+ ```bash
133
+ npm install -g @artik0din/turbogha
134
+ # or
135
+ npx @artik0din/turbogha
136
+ ```
137
+
138
+ ### Commands
139
+
140
+ ```bash
141
+ # Start cache server (background)
142
+ turbogha start
143
+
144
+ # Start in foreground (for debugging)
145
+ turbogha start --foreground
146
+
147
+ # Check server status
148
+ turbogha ping
149
+
150
+ # Stop server
151
+ turbogha kill
152
+ ```
153
+
154
+ ### Local Configuration
155
+
156
+ Create `.env` in your project root:
157
+
158
+ ```env
159
+ # Storage provider
160
+ PROVIDER=s3
161
+
162
+ # S3 credentials
163
+ AWS_ACCESS_KEY_ID=your-key
164
+ AWS_SECRET_ACCESS_KEY=your-secret
165
+ AWS_REGION=us-east-1
166
+ S3_BUCKET=my-bucket
167
+ S3_PREFIX=turbogha/
168
+
169
+ # Optional
170
+ SERVER_PORT=41230
171
+ CACHE_PREFIX=local_
172
+ ```
173
+
174
+ ### Using with Turbo
175
+
176
+ ```bash
177
+ # Start the server
178
+ turbogha start
179
+
180
+ # Configure Turbo (add to .bashrc/.zshrc for persistence)
181
+ export TURBO_API=http://localhost:41230
182
+ export TURBO_TOKEN=turbogha
183
+ export TURBO_TEAM=turbogha
184
+
185
+ # Run builds with remote caching
186
+ turbo build
187
+ ```
188
+
189
+ ## Inputs Reference
190
+
191
+ | Input | Description | Default |
192
+ |-------|-------------|---------|
193
+ | `provider` | Storage backend (`github` or `s3`) | `github` |
194
+ | `cache-prefix` | Cache key prefix | `turbogha_` |
195
+ | `server-port` | Local server port | `41230` |
196
+ | `max-age` | Max cache age (e.g., `1w`, `1mo`) | - |
197
+ | `max-files` | Max number of cached files | - |
198
+ | `max-size` | Max total cache size (e.g., `5gb`) | - |
199
+ | `s3-access-key-id` | AWS access key ID | - |
200
+ | `s3-secret-access-key` | AWS secret access key | - |
201
+ | `s3-session-token` | AWS session token (for OIDC) | - |
202
+ | `s3-bucket` | S3 bucket name | - |
203
+ | `s3-region` | S3 region | - |
204
+ | `s3-endpoint` | S3 endpoint URL | `https://s3.amazonaws.com` |
205
+ | `s3-prefix` | S3 object prefix | `turbogha/` |
206
+
207
+ ## Examples
208
+
209
+ ### Monorepo with Multiple Apps
210
+
211
+ ```yaml
212
+ jobs:
213
+ build:
214
+ runs-on: ubuntu-latest
215
+ steps:
216
+ - uses: actions/checkout@v4
217
+
218
+ - uses: globodai-group/caching-for-turbo@v1
219
+ with:
220
+ cache-prefix: ${{ github.repository }}_
221
+
222
+ - run: npm ci
223
+ - run: turbo build --filter=@myorg/web
224
+ - run: turbo build --filter=@myorg/api
225
+ ```
226
+
227
+ ### Matrix Build with Isolated Caches
228
+
229
+ ```yaml
230
+ jobs:
231
+ build:
232
+ strategy:
233
+ matrix:
234
+ os: [ubuntu-latest, windows-latest, macos-latest]
235
+ runs-on: ${{ matrix.os }}
236
+ steps:
237
+ - uses: actions/checkout@v4
238
+
239
+ - uses: globodai-group/caching-for-turbo@v1
240
+ with:
241
+ cache-prefix: ${{ matrix.os }}_
242
+
243
+ - run: npm ci
244
+ - run: turbo build test lint
245
+ ```
246
+
247
+ ### S3 with Automatic Cleanup
248
+
249
+ ```yaml
250
+ - uses: globodai-group/caching-for-turbo@v1
251
+ with:
252
+ provider: s3
253
+ s3-bucket: ${{ vars.CACHE_BUCKET }}
254
+ s3-region: eu-west-1
255
+ s3-access-key-id: ${{ secrets.AWS_KEY }}
256
+ s3-secret-access-key: ${{ secrets.AWS_SECRET }}
257
+ max-age: 1w
258
+ max-size: 10gb
259
+ ```
260
+
261
+ ## Performance Tips
262
+
263
+ 1. **Use cache prefixes** to isolate caches between branches/PRs
264
+ 2. **Set cleanup policies** to prevent cache bloat (especially with S3)
265
+ 3. **Use S3** for very large caches or cross-workflow sharing
266
+ 4. **Run cache server early** in your workflow for maximum benefit
267
+
268
+ ## Troubleshooting
269
+
270
+ ### Cache not being used
271
+
272
+ - Ensure the action runs **before** any `turbo` commands
273
+ - Check that `TURBO_API`, `TURBO_TOKEN`, `TURBO_TEAM` are set
274
+ - Verify no conflicting Turbo remote cache configuration
275
+
276
+ ### Server fails to start
277
+
278
+ - Check if port 41230 is available
279
+ - Try a different port with `server-port` input
280
+ - Check workflow logs for detailed error messages
281
+
282
+ ### S3 connection issues
283
+
284
+ - Verify credentials have `s3:GetObject`, `s3:PutObject`, `s3:ListBucket` permissions
285
+ - Check bucket region matches `s3-region` input
286
+ - For custom endpoints, ensure `s3-endpoint` is correctly formatted
287
+
288
+ ## Contributing
289
+
290
+ ```bash
291
+ # Clone the repository
292
+ git clone https://github.com/globodai-group/caching-for-turbo.git
293
+ cd caching-for-turbo
294
+
295
+ # Install dependencies
296
+ npm install
297
+
298
+ # Run development server
299
+ npm run dev-run
300
+
301
+ # Build
302
+ npm run bundle
303
+
304
+ # Lint
305
+ npm run lint
306
+ ```
307
+
308
+ ## License
309
+
310
+ MIT License - see [LICENSE](LICENSE) for details.
311
+
312
+ ## Credits
313
+
314
+ Built with inspiration from:
315
+ - [rharkor/caching-for-turbo](https://github.com/rharkor/caching-for-turbo) - Original implementation
316
+ - [dtinth/setup-github-actions-caching-for-turbo](https://github.com/dtinth/setup-github-actions-caching-for-turbo) - Original concept
317
+
318
+ ---
319
+
320
+ <p align="center">
321
+ Made with care by <a href="https://github.com/globodai-group">Globodai Group</a>
322
+ </p>