name: Storage R2 S3-compatible Integration on: push: branches: [dev, next, main] paths: - "packages/storage-r2/**" - "packages/storage/**" - "packages/observability/**" - "package.json" - "package-lock.json" - "scripts/ci-install-rollup-native.mjs" - ".github/workflows/storage-r2-minio.yml" pull_request: branches: [dev, next, main] paths: - "packages/storage-r2/**" - "packages/storage/**" - "packages/observability/**" - "package.json" - "package-lock.json" - "scripts/ci-install-rollup-native.mjs" - ".github/workflows/storage-r2-minio.yml" permissions: contents: read jobs: test: name: R2 adapter against a MinIO server (Node and workerd) if: github.repository == '21nCo/superfunctions' runs-on: ubuntu-24.04 services: minio: # The upstream minio/minio image needs a `server` argument, which service containers cannot pass; this one starts the server itself. image: bitnamilegacy/minio:2025.7.23@sha256:8935e75fa5d11295c17171e4aa49efe390a1193cd7f12e4d21b92af9ffef09d7 env: # Disposable per-run credentials for the throwaway service container. The job env below repeats the same # expressions byte for byte (service env cannot read the env context). Each value is one ${{ }} expression with # no literal text outside it, so secret scanners see a templated value rather than a hard-coded credential. MINIO_ROOT_USER: ${{ format('r2-ci-{0}-{1}', github.run_id, github.run_attempt) }} MINIO_ROOT_PASSWORD: ${{ format('r2-ci-key-{0}-{1}', github.run_id, github.run_attempt) }} MINIO_DEFAULT_BUCKETS: filefn-r2-test ports: - 9000:9000 options: >- --health-cmd "curl -fsS http://localhost:9000/minio/health/live" --health-interval 5s --health-timeout 5s --health-retries 20 env: STORAGE_R2_S3_ENDPOINT: http://127.0.0.1:9000 STORAGE_R2_S3_BUCKET: filefn-r2-test STORAGE_R2_S3_ACCESS_KEY_ID: ${{ format('r2-ci-{0}-{1}', github.run_id, github.run_attempt) }} STORAGE_R2_S3_SECRET_ACCESS_KEY: ${{ format('r2-ci-key-{0}-{1}', github.run_id, github.run_attempt) }} STORAGE_R2_S3_REQUIRED: "1" steps: - name: Checkout repository uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: persist-credentials: false - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: "22" cache: npm cache-dependency-path: package-lock.json - name: Install the storage-r2 workspace and its workspace dependencies from the root lockfile run: >- npm ci --ignore-scripts --include-workspace-root=false --workspace @superfunctions/observability --workspace @superfunctions/storage --workspace @superfunctions/storage-r2 - name: Build trusted esbuild native binding run: npm rebuild esbuild - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Build workspace dependencies (@superfunctions/storage exports resolve to dist/) run: | npm run build --workspace @superfunctions/observability npm run build --workspace @superfunctions/storage # The image creates the bucket after the server reports live. MinIO answers # an anonymous request 403 AccessDenied whether or not the bucket exists, so # readiness is a signed HeadBucket: 404 until the bucket exists, 200 after. # Only 200 counts as ready. Connection failures, timeouts, 404 and 5xx are # retried, and the step fails when the attempts run out. - name: Wait for the test bucket run: | for attempt in $(seq 1 30); do status="$(curl -sS -o /dev/null -w '%{http_code}' --head --connect-timeout 2 --max-time 5 \ -H "x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" \ --aws-sigv4 "aws:amz:us-east-1:s3" \ --user "$STORAGE_R2_S3_ACCESS_KEY_ID:$STORAGE_R2_S3_SECRET_ACCESS_KEY" \ "$STORAGE_R2_S3_ENDPOINT/$STORAGE_R2_S3_BUCKET" || true)" if [ "$status" = "200" ]; then echo "bucket $STORAGE_R2_S3_BUCKET is ready (attempt $attempt)" exit 0 fi echo "attempt $attempt: HeadBucket returned HTTP ${status:-none}" sleep 2 done echo "::error::bucket $STORAGE_R2_S3_BUCKET was not ready after 30 attempts (last HTTP ${status:-none})" exit 1 - name: Typecheck run: npm run typecheck --workspace @superfunctions/storage-r2 - name: Run Node and workerd suites, including the MinIO conformance and Worker bundle checks run: npm test --workspace @superfunctions/storage-r2