Compare commits

..

1 Commits

Author SHA1 Message Date
Pandey
c110e14505 ci: add cacheci workflow to maintain shared go and pnpm caches (#12368)
Some checks are pending
cacheci / tests (push) Waiting to run
build-staging / prepare (push) Waiting to run
build-staging / js-build (push) Blocked by required conditions
build-staging / go-build (push) Blocked by required conditions
build-staging / staging (push) Blocked by required conditions
Release Drafter / update_release_draft (push) Waiting to run
2026-08-01 16:11:09 +00:00
4 changed files with 87 additions and 16 deletions

86
.github/workflows/cacheci.yml vendored Normal file
View File

@@ -0,0 +1,86 @@
name: cacheci
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
actions: write
concurrency:
group: cacheci
cancel-in-progress: false
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: restore
id: restore
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/cacheci
key: tests-primary
restore-keys: |
tests-secondary
- name: inject
if: steps.restore.outputs.cache-matched-key != ''
run: |
cat > "$RUNNER_TEMP/inject.Dockerfile" <<'EOF'
FROM busybox:1.37
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/pnpm/store \
--mount=type=bind,target=/restored \
cp -a /restored/go-build/. /root/.cache/go-build/ && \
cp -a /restored/go-mod/. /go/pkg/mod/ && \
cp -a /restored/pnpm-store/. /pnpm/store/
EOF
docker build -f "$RUNNER_TEMP/inject.Dockerfile" "$RUNNER_TEMP/cacheci"
- name: build
run: |
docker build -f cmd/enterprise/Dockerfile.integration --build-arg TARGETARCH=amd64 --build-arg ZEUSURL=http://zeus:8080 .
docker build -f cmd/enterprise/Dockerfile.with-web.integration --build-arg TARGETARCH=amd64 --build-arg ZEUSURL=http://zeus:8080 .
- name: extract
run: |
rm -rf "$RUNNER_TEMP/cacheci"
mkdir -p "$RUNNER_TEMP/extract-context"
cat > "$RUNNER_TEMP/extract.Dockerfile" <<'EOF'
FROM busybox:1.37 AS mounts
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/pnpm/store \
mkdir -p /out/go-build /out/go-mod /out/pnpm-store && \
cp -a /root/.cache/go-build/. /out/go-build/ && \
cp -a /go/pkg/mod/. /out/go-mod/ && \
cp -a /pnpm/store/. /out/pnpm-store/
FROM scratch
COPY --from=mounts /out/ /
EOF
docker build -f "$RUNNER_TEMP/extract.Dockerfile" --output "type=local,dest=$RUNNER_TEMP/cacheci" "$RUNNER_TEMP/extract-context"
# Fixed cache keys are immutable, so each key must be deleted before it
# can be saved again. Rotating primary and secondary one after the other
# keeps at least one key restorable for concurrent test runs.
- name: delete-primary
env:
GH_TOKEN: ${{ github.token }}
run: gh cache delete tests-primary --repo "$GITHUB_REPOSITORY" || true
- name: save-primary
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/cacheci
key: tests-primary
- name: delete-secondary
env:
GH_TOKEN: ${{ github.token }}
run: gh cache delete tests-secondary --repo "$GITHUB_REPOSITORY" || true
- name: save-secondary
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/cacheci
key: tests-secondary

View File

@@ -258,7 +258,6 @@ Tests can be configured using pytest options:
- `--clickhouse-version` — ClickHouse version, also used for ClickHouse Keeper (default: `25.12.5`)
- `--schema-migrator-version` — SigNoz schema migrator version (default: `v0.144.6`)
- `--with-web` — Build the frontend into the SigNoz image (required for e2e)
- `--zeus-network-alias` — Give the zeus WireMock container a fixed network alias (e.g. `--zeus-network-alias zeus`) so the SigNoz image build args are deterministic; used by CI to share one image across jobs. Don't flip it between runs of a `--reuse` environment (cached container configs would go stale).
Example:

View File

@@ -81,12 +81,6 @@ def pytest_addoption(parser: pytest.Parser):
default=False,
help="Build and run with web. Run pytest --basetemp=./tmp/ -vv --with-web src/bootstrap/setup::test_setup to setup your local dev environment with web.",
)
parser.addoption(
"--zeus-network-alias",
action="store",
default="",
help="Give the zeus WireMock container a fixed network alias (e.g. --zeus-network-alias zeus) so the signoz image build args are deterministic; used by CI to share one image across jobs. Do not flip this option between runs of a --reuse environment: cached container configs would go stale.",
)
parser.addoption(
"--sqlstore-provider",
action="store",

View File

@@ -31,16 +31,8 @@ def zeus(
def create() -> types.TestContainerDocker:
container = WireMockContainer(image="wiremock/wiremock:2.35.1-1", secure=False)
container.with_network(network)
network_alias = pytestconfig.getoption("--zeus-network-alias")
if network_alias:
container.with_network_aliases(network_alias)
container.start()
if network_alias:
container_address = network_alias
else:
container_address = container.get_wrapped_container().name
return types.TestContainerDocker(
id=container.get_wrapped_container().id,
host_configs={
@@ -50,7 +42,7 @@ def zeus(
container.get_exposed_port(8080),
)
},
container_configs={"8080": types.TestContainerUrlConfig("http", container_address, 8080)},
container_configs={"8080": types.TestContainerUrlConfig("http", container.get_wrapped_container().name, 8080)},
)
def delete(container: types.TestContainerDocker):