Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bcr_test_module:
module_path: "examples/simple"
module_path: "e2e/smoke"
matrix:
platform: ["debian10", "macos", "ubuntu2004"]
bazel: ["8.x"]
Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ PREFIX="rules_formatjs-${TAG:1}"
ARCHIVE="rules_formatjs-$TAG.tar.gz"

# NB: configuration for 'git archive' is in /.gitattributes
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
# Create the main archive
git archive --format=tar --prefix=${PREFIX}/ ${TAG} > "${ARCHIVE%.gz}"

# Add e2e/smoke test to the archive (examples are excluded by .gitattributes but we want smoke test included)
# Create a temporary directory with the smoke test in the right structure
TMPDIR=$(mktemp -d)
mkdir -p "${TMPDIR}/${PREFIX}/e2e"
# Copy smoke test but exclude bazel output directories and lock files
rsync -a --exclude='bazel-*' --exclude='MODULE.bazel.lock' e2e/smoke/ "${TMPDIR}/${PREFIX}/e2e/smoke/"
tar -rf "${ARCHIVE%.gz}" -C "${TMPDIR}" .
rm -rf "${TMPDIR}"

# Compress the archive
gzip "${ARCHIVE%.gz}"

SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

# Add generated API docs to the release, see https://github.com/bazelbuild/bazel-central-registry/issues/5593
Expand All @@ -34,4 +48,15 @@ bazel_dep(name = "rules_formatjs", version = "${TAG:1}")
\`\`\`

That's it! The toolchains are automatically registered.

## Testing the Installation

A smoke test is included in the release at \`e2e/smoke/\`. To verify the rules work in your environment:

\`\`\`bash
cd e2e/smoke
bazel build //:extract
\`\`\`

This will extract messages from a simple React component and verify that the FormatJS CLI toolchain is working correctly.
EOF
2 changes: 2 additions & 0 deletions e2e/smoke/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Minimal bazelrc for smoke test
common --enable_bzlmod
8 changes: 8 additions & 0 deletions e2e/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_formatjs//formatjs:defs.bzl", "formatjs_extract")

# Extract messages from source files
formatjs_extract(
name = "extract",
srcs = ["src/Hello.tsx"],
out = "messages.json",
)
12 changes: 12 additions & 0 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Smoke test for rules_formatjs - minimal test to verify basic functionality"""

module(
name = "smoke_test",
version = "0.0.0",
)

bazel_dep(name = "rules_formatjs", version = "0.0.0")
local_path_override(
module_name = "rules_formatjs",
path = "../..",
)
295 changes: 295 additions & 0 deletions e2e/smoke/MODULE.bazel.lock

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions e2e/smoke/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Smoke Test

This is a minimal end-to-end test that verifies basic functionality of `rules_formatjs`.

## Purpose

This smoke test is included in the release artifact to allow users to quickly verify that the rules work in their environment without needing to set up a complex example.

## What it tests

- Basic message extraction from a React component using `formatjs_extract`
- FormatJS CLI toolchain selection and execution
- Module extension setup and toolchain registration

## Running the test

From this directory:

```bash
bazel build //:extract
```

This should successfully extract messages from `src/Hello.tsx` and produce a `messages.json` file with the extracted internationalization messages.

## Expected output

The build should succeed and produce `bazel-bin/messages.json` containing:

```json
{
"hello.world": {
"id": "hello.world",
"defaultMessage": "Hello, World!",
"description": "Simple greeting message"
}
}
```
1 change: 1 addition & 0 deletions e2e/smoke/REPO.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for Bazel workspace
13 changes: 13 additions & 0 deletions e2e/smoke/src/Hello.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { FormattedMessage } from "react-intl";

export function Hello() {
return (
<div>
<FormattedMessage
id="hello.world"
defaultMessage="Hello, World!"
description="Simple greeting message"
/>
</div>
);
}
Loading