Skip to content

Commit 8eaa72b

Browse files
nicklaslclaude
andcommitted
test: introduce separate e2e stage
feat: add e2e test support in Docker builds - Add all-e2e target that runs e2e tests with credentials - Default docker build skips e2e tests (no credentials needed) - CI runs all-e2e target with GitHub secrets - E2E tests skip gracefully when credentials not provided 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 68fd049 commit 8eaa72b

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
uses: docker/build-push-action@v6
3535
with:
3636
context: .
37-
target: all
37+
target: all-e2e
3838
push: false
3939
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
4040
build-args: |
@@ -46,7 +46,7 @@ jobs:
4646
uses: docker/build-push-action@v6
4747
with:
4848
context: .
49-
target: all
49+
target: all-e2e
5050
push: false
5151
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
5252
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max

Dockerfile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,29 @@ FROM openfeature-provider-js-base AS openfeature-provider-js.test
399399
COPY confidence-resolver/protos ../../../confidence-resolver/protos
400400
COPY wasm/resolver_state.pb ../../../wasm/resolver_state.pb
401401

402+
# Run tests
403+
RUN make test
404+
405+
# ==============================================================================
406+
# E2E Test OpenFeature Provider (CI only - requires credentials)
407+
# ==============================================================================
408+
FROM openfeature-provider-js.test AS openfeature-provider-js.test_e2e
409+
402410
# Accept e2e test credentials as build args (not persisted in image)
403411
ARG JS_E2E_CONFIDENCE_API_CLIENT_ID
404412
ARG JS_E2E_CONFIDENCE_API_CLIENT_SECRET
405413

406-
# Run tests with secrets passed as environment variables
414+
# Run e2e tests with secrets passed as environment variables
415+
# If credentials are not provided, skip e2e tests (exit 0)
407416
# Using ARG in RUN means they're only available during this command execution
408417
RUN --mount=type=cache,target=/root/.yarn \
409-
JS_E2E_CONFIDENCE_API_CLIENT_ID="${JS_E2E_CONFIDENCE_API_CLIENT_ID}" \
410-
JS_E2E_CONFIDENCE_API_CLIENT_SECRET="${JS_E2E_CONFIDENCE_API_CLIENT_SECRET}" \
411-
make test
418+
if [ -n "${JS_E2E_CONFIDENCE_API_CLIENT_ID}" ] && [ -n "${JS_E2E_CONFIDENCE_API_CLIENT_SECRET}" ]; then \
419+
JS_E2E_CONFIDENCE_API_CLIENT_ID="${JS_E2E_CONFIDENCE_API_CLIENT_ID}" \
420+
JS_E2E_CONFIDENCE_API_CLIENT_SECRET="${JS_E2E_CONFIDENCE_API_CLIENT_SECRET}" \
421+
make test-e2e; \
422+
else \
423+
echo "Skipping e2e tests (credentials not provided)"; \
424+
fi
412425

413426
# ==============================================================================
414427
# Build OpenFeature Provider
@@ -466,7 +479,7 @@ FROM openfeature-provider-java-base AS openfeature-provider-java.build
466479
RUN make build
467480

468481
# ==============================================================================
469-
# All - Build and validate everything (default target)
482+
# All - Build and validate everything (default target - no e2e tests)
470483
# ==============================================================================
471484
FROM scratch AS all
472485

@@ -494,3 +507,15 @@ COPY --from=wasm-rust-guest.lint /workspace/Cargo.toml /markers/lint-guest
494507
COPY --from=openfeature-provider-js.build /app/dist/index.node.js /artifacts/openfeature-js/
495508
COPY --from=openfeature-provider-java.build /app/target/*.jar /artifacts/openfeature-java/
496509
COPY --from=confidence-cloudflare-resolver.lint /workspace/Cargo.toml /markers/lint-cloudflare
510+
511+
# ==============================================================================
512+
# All E2E - Build and validate everything including e2e tests (CI only)
513+
# ==============================================================================
514+
FROM scratch AS all-e2e
515+
516+
# Copy everything from main all target
517+
COPY --from=all /artifacts /artifacts
518+
COPY --from=all /markers /markers
519+
520+
# Additionally force e2e test stage to run
521+
COPY --from=openfeature-provider-js.test_e2e /app/package.json /markers/test-openfeature-js-e2e

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ The Confidence Flag Resolver implemented in Rust, plus example hosts and a Cloud
2828
docker build . # Build, test, lint everything
2929
make # Same, using Makefile
3030

31-
# With Docker + e2e tests (requires Confidence credentials)
32-
docker build \
31+
# With Docker + e2e tests (requires Confidence credentials - used in CI)
32+
docker build --target all-e2e \
3333
--build-arg JS_E2E_CONFIDENCE_API_CLIENT_ID=<your-client-id> \
3434
--build-arg JS_E2E_CONFIDENCE_API_CLIENT_SECRET=<your-secret> \
3535
.

openfeature-provider/js/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ install: $(INSTALL_STAMP) $(GEN_TS)
4242
build: $(BUILD_STAMP)
4343

4444
test: $(WASM_ARTIFACT) $(INSTALL_STAMP) $(GEN_TS)
45+
yarn test --run --exclude='**/*.e2e.test.ts'
46+
47+
test-e2e: $(WASM_ARTIFACT) $(INSTALL_STAMP) $(GEN_TS)
4548
yarn test --run
4649

4750
clean:

0 commit comments

Comments
 (0)