Skip to content

Commit dcb5fdb

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
* upstream/dev: chore(release): v7.0.1 fix: execute delete query for pruning uploads (#123) docs: use correct env var name for cache cleanup (#125) ci(release): push also tag `dev` chore(release): v7.0.0 docs: add `zstd` info feat: proxy unknown requests to default GitHub `ACTIONS_RESULTS_URL` & revive v1 support build(docker): use cluster size of 1 by default chore(helm): add proxy port 8000 feat!: drop cache service v1 support fix(proxy): disable passthrough websockets feat(proxy): enable http2 feat(proxy): only tls intercept required hostname feat: enable nitro `node-cluster` preset feat: enable proxy debug logs if debug enabled test: add random path prefix to `ACTIONS_CACHE_URL` chore(release): v6.0.1 fix: handle random path prefix for cache service v1 routes chore(release): v6.0.0 feat!: binary patching alternative (#112)
2 parents 166a548 + 3e7178a commit dcb5fdb

File tree

28 files changed

+996
-416
lines changed

28 files changed

+996
-416
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ node_modules/
77
data/
88
.env*
99
.eslintcache
10-
test/
10+
test/
11+
certs/

.github/workflows/ci-cd.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ jobs:
5050
- name: pnpm install
5151
uses: falcondev-it/.github/actions/pnpm-install@master
5252

53-
- run: VITEST_DB_DRIVER=${{ matrix.db-driver }} VITEST_STORAGE_DRIVER=${{ matrix.storage-driver }} pnpm run test:run
53+
- run: pnpm run test:run
54+
env:
55+
VITEST_DB_DRIVER: ${{ matrix.db-driver }}
56+
VITEST_STORAGE_DRIVER: ${{ matrix.storage-driver }}
5457

5558
deploy:
5659
if: github.event.ref == 'refs/heads/dev'

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
5656
npx bumpp ${{ env[inputs.version] }} -y -r --commit "chore(release): v%s" --no-push
5757
58-
export VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
58+
export VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
5959
sed -E "s/^appVersion:.+$/appVersion: '$VERSION'/" -i install/kubernetes/github-actions-cache-server/Chart.yaml
6060
git stage install/kubernetes/github-actions-cache-server/Chart.yaml
6161
git commit -n --no-edit --amend
@@ -113,6 +113,7 @@ jobs:
113113
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.RELEASE_TAG }}
114114
type=semver,pattern={{major}},value=${{ needs.release.outputs.RELEASE_TAG }}
115115
latest
116+
dev
116117
117118
- name: Login to GitHub Container Registry
118119
uses: docker/login-action@v3

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ data/
1010
.data
1111
.idea
1212
.DS_Store
13-
tests/temp/
13+
tests/temp/
14+
actions-runner/

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ RUN pnpm run build
2121

2222
FROM node:22-alpine as runner
2323

24+
ENV NITRO_CLUSTER_WORKERS=1
25+
2426
WORKDIR /app
2527

2628
COPY --from=builder /app/.output ./

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ This is a drop-in replacement for the official GitHub hosted cache server. It is
1010
- 😎 Easy setup
1111

1212
```yaml
13-
version: '3.9'
14-
1513
services:
1614
cache-server:
1715
image: ghcr.io/falcondev-oss/github-actions-cache-server

docs/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default defineAppConfig({
3030
],
3131
},
3232
footer: {
33-
credits: 'Copyright © 2024',
33+
credits: 'Made wih ❤️ by @falcondev-oss',
3434
colorMode: false,
3535
links: [
3636
{

docs/content/1.getting-started/1.index.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
---
22
title: Getting Started
3-
description: Deploy the GitHub Actions Cache Server using Docker and use it with self-hosted runners
3+
description: Deploy the Cache Server with Docker and self-hosted runners
44
---
55

6-
The cache server comes as a Docker image and can be deployed using Docker Compose or Kubernetes.
6+
The cache server is available as a Docker image and can be deployed via Docker Compose or Kubernetes.
77

88
## 1. Deploying the Cache Server
99

1010
```yaml [docker-compose.yml]
11-
version: '3.9'
12-
1311
services:
1412
cache-server:
1513
image: ghcr.io/falcondev-oss/github-actions-cache-server:latest
@@ -60,54 +58,62 @@ variant: subtle
6058
---
6159
::
6260

63-
#### `CLEANUP_OLDER_THAN_DAYS`
61+
#### `CACHE_CLEANUP_OLDER_THAN_DAYS`
6462

6563
- Default: `90`
6664

6765
The number of days to keep stale cache data and metadata before deleting it. Set to `0` to disable cache cleanup.
6866

67+
#### `CACHE_CLEANUP_CRON`
68+
69+
- Default: `0 0 * * *`
70+
71+
The cron schedule for running the cache cleanup job.
72+
73+
#### `UPLOAD_CLEANUP_CRON`
74+
75+
- Default: `*/10 * * * *`
76+
77+
The cron schedule for running the upload cleanup job. This job will delete any dangling (failed or incomplete) uploads.
78+
79+
6980
#### `NITRO_PORT`
7081

7182
- Default: `3000`
7283

7384
The port the server should listen on.
7485

75-
## 2. Setup with Self-Hosted Runners
86+
#### `TEMP_DIR`
7687

77-
To leverage the GitHub Actions Cache Server with your self-hosted runners, you'll need to configure a couple of environment variables on your runners. This ensures that your runners can authenticate with and utilize the cache server effectively.
88+
- Default: os temp dir
7889

79-
### Configuring Environment Variables on Self-Hosted Runners
90+
The directory to use for temporary files.
8091

81-
**`ACTIONS_RESULTS_URL`**: This tells your self-hosted runner where to send cache requests. Set this environment variable to the `API_BASE_URL` of your cache server, making sure to include a trailing slash.
92+
## 2. Setup with Self-Hosted Runners
8293

83-
For example, if your cache server's `API_BASE_URL` is `http://localhost:3000`, you would set `ACTIONS_RESULTS_URL` to `http://localhost:3000/`.
94+
Set the `ACTIONS_RESULTS_URL` on your runner to the API URL (with a trailing slash).
8495

8596
::u-alert
8697
---
8798
icon: 'tabler:alert-triangle'
8899
class: ring-amber-400
89100
color: amber
90-
description: Make sure to add a trailing slash to the ACTIONS_RESULTS_URL environment variable.
101+
description: Ensure ACTIONS_RESULTS_URL ends with a trailing slash.
91102
variant: subtle
92103
---
93104
::
94105

95-
### Getting the Actions Runner to Use the Cache Server
96-
97-
The default self-hosted runner overwrites the `ACTIONS_RESULTS_URL` environment variable with the GitHub-hosted cache server URL. To get the runner to use your self-hosted cache server, you'll need to modify the runner binary:
98-
99-
#### Docker
106+
### Runner Configuration
100107

101-
Just add the following lines to your Dockerfile:
108+
For Docker:
102109

103110
```dockerfile [Dockerfile]
104111
FROM ghcr.io/actions/actions-runner:latest
105-
106-
# modify actions runner binaries to allow custom cache server implementation
112+
# Modify runner binary to retain custom ACTIONS_RESULTS_URL
107113
RUN sed -i 's/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x55\x00\x52\x00\x4C\x00/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x4F\x00\x52\x00\x4C\x00/g' /home/runner/bin/Runner.Worker.dll
108114
```
109115

110-
#### Bare Metal
116+
For Bare Metal, similar commands apply:
111117

112118
::code-group
113119

@@ -125,9 +131,17 @@ gsed -i 's/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\
125131

126132
::
127133

128-
This will replace the strings `ACTIONS_RESULTS_URL` with `ACTIONS_RESULTS_ORL` in the runner binary. This will prevent the runner from overwriting the `ACTIONS_RESULTS_URL` environment variable and allow it to use your self-hosted cache server.
134+
This patch prevents the runner from overwriting your custom `ACTIONS_RESULTS_URL`.
129135

130-
Doing it this way is a bit of a hack, but it's easier than compiling your own runner binary from source and works great.
136+
::u-alert
137+
---
138+
icon: 'tabler:info-circle'
139+
class: ring-blue-400
140+
color: blue
141+
description: It is recommended to install zstd on your runners for faster compression and decompression.
142+
variant: subtle
143+
---
144+
::
131145

132146
## 3. Using the Cache Server
133147

docs/content/1.getting-started/4.how-it-works.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
---
22
title: How it works
3-
description: Learn how we built the GitHub Actions Cache Server and how it works without any workflow file changes
3+
description: How the cache server integrates with GitHub Actions
44
---
55

6-
## 1. Reverse-Engineering the cache server
6+
## 1. Reverse-Engineering
77

8-
This is actually a pretty simple process. We just need to look at the requests that the GitHub Actions runner makes to the cache server and then replicate the api routes. We can use the source code of the official `actions/cache` action to see how the requests are made.
8+
We replicate the official cache API by examining runner requests and the actions/cache source. See GitHub docs on cache keys.
99

10-
GitHub also has very good [documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) on how the cache keys are matched.
10+
## 2. Configuring the Runner
1111

12-
## 2. Getting the actions runner to use our cache server
13-
14-
The whole idea of creating a self-hosted cache server originated from the discovery that the official `actions/cache` action uses an environment variable `ACTIONS_RESULTS_URL` to determine where to send cache requests. This means that we can simply set this environment variable to the base URL of our cache server and the runner will start using it ...right?
15-
16-
Well, not exactly. The `actions/cache` action uses the `ACTIONS_RESULTS_URL` environment variable to determine the base URL of the cache server but we cannot overrid this environment variable in any way.
17-
18-
The default actions runner always overrides the `ACTIONS_RESULTS_URL` environment variable with an internal URL that points to the official GitHub cache server. This is the code that does it:
12+
The runner overrides ACTIONS_RESULTS_URL with its internal endpoint. We patched the binary by replacing "ACTIONS_RESULTS_URL" with "ACTIONS_RESULTS_ORL" (keeping the same length) to allow a custom cache URL.
1913

2014
```c#
2115
var systemConnection = ExecutionContext.Global.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
@@ -44,7 +38,3 @@ if (ExecutionContext.Global.Variables.GetBoolean("actions_uses_cache_service_v2"
4438
Environment["ACTIONS_CACHE_SERVICE_V2"] = bool.TrueString;
4539
}
4640
```
47-
48-
The line `Environment["ACTIONS_RESULTS_URL"] = resultsUrl;` is the one that overrides the `ACTIONS_RESULTS_URL` environment variable with the internal URL.
49-
50-
To allow overriding the `ACTIONS_RESULTS_URL` environment variable, we need to modify the runner binary. This is a bit tricky because the runner is a compiled binary and we cannot simply modify the source code and recompile it. We need to modify the binary itself. So we did just that. We replaced the string `ACTIONS_RESULTS_URL` with `ACTIONS_RESULTS_ORL` (being careful to keep the same length) in the runner binary. This way, the runner will not override the `ACTIONS_RESULTS_URL` environment variable and we can set it to our cache server's base URL.

docs/content/index.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ hero:
1313
size: lg
1414
code: |
1515
```yaml [docker-compose.yml]
16-
version: '3.9'
17-
1816
services:
1917
cache-server:
2018
image: ghcr.io/falcondev-oss/github-actions-cache-server:latest

0 commit comments

Comments
 (0)