Skip to content

Commit 2b1fcdb

Browse files
committed
feat: switch to native formatjs cli
1 parent 7ecf366 commit 2b1fcdb

44 files changed

Lines changed: 851 additions & 1175 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
os: [ubuntu-latest, macos-latest]
1717
folder:
1818
- "."
19-
- "e2e/smoke"
2019
- "examples/simple"
2120
- "examples/aggregate"
2221
runs-on: ${{ matrix.os }}
@@ -28,22 +27,3 @@ jobs:
2827
- name: Test ${{ matrix.folder }}
2928
working-directory: ${{ matrix.folder }}
3029
run: bazel test //...
31-
32-
pre-commit:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v5
36-
- uses: pre-commit/action@v3.0.1
37-
38-
conclusion:
39-
needs: [test, pre-commit]
40-
runs-on: ubuntu-latest
41-
if: always()
42-
steps:
43-
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # v3.0.3
44-
- name: Report success
45-
if: ${{ env.WORKFLOW_CONCLUSION == 'success' }}
46-
run: exit 0
47-
- name: Report failure
48-
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }}
49-
run: exit 1

.github/workflows/verify-hooks.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Verify Hooks
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
jobs:
8+
verify-hooks:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v5
12+
with:
13+
fetch-depth: 100
14+
- uses: pnpm/action-setup@v4
15+
with:
16+
version: 10
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 24
20+
cache: pnpm
21+
- name: Install dependencies
22+
run: pnpm install --frozen-lockfile
23+
- uses: bazel-contrib/setup-bazel@0.16.0
24+
with:
25+
bazelisk-cache: true
26+
- name: Get changed files
27+
id: changed-files
28+
run: |
29+
if [ "${{ github.event_name }}" = "pull_request" ]; then
30+
git fetch origin ${{ github.base_ref }}
31+
echo "files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT
32+
else
33+
echo "files=$(git diff --name-only HEAD~1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT
34+
fi
35+
- name: Run lefthook on changed files
36+
if: steps.changed-files.outputs.files != ''
37+
run: |
38+
# Stage the changed files
39+
for file in ${{ steps.changed-files.outputs.files }}; do
40+
if [ -f "$file" ]; then
41+
git add "$file"
42+
fi
43+
done
44+
45+
# Run pre-commit hooks
46+
pnpm exec lefthook run pre-commit
47+
48+
# Check if any files were modified by the hooks
49+
if ! git diff --quiet; then
50+
echo "Error: Hooks modified files. Please run 'pnpm exec lefthook run pre-commit' locally and commit the changes."
51+
git diff
52+
exit 1
53+
fi
54+
- name: Validate commit messages
55+
if: github.event_name == 'pull_request'
56+
run: |
57+
# Get all commits in the PR
58+
commits=$(git log origin/${{ github.base_ref }}..HEAD --format=%H)
59+
60+
for commit in $commits; do
61+
echo "Validating commit: $commit"
62+
message=$(git log -1 --format=%B $commit)
63+
64+
# Save message to temporary file
65+
echo "$message" > /tmp/commit-msg
66+
67+
# Run commit-msg hook
68+
if command -v cz &> /dev/null; then
69+
cz check --commit-msg-file /tmp/commit-msg || exit 1
70+
else
71+
echo "commitizen not installed, skipping commit message validation for $commit"
72+
fi
73+
done

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ bazel-*
22
.bazelrc.user
33
.idea/
44
.ijwb/
5+
node_modules/

.pre-commit-config.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

BUILD.bazel

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
21
load("@package_metadata//licenses/rules:license.bzl", "license")
32
load("@package_metadata//purl:purl.bzl", "purl")
43
load("@package_metadata//rules:package_metadata.bzl", "package_metadata")
@@ -17,14 +16,3 @@ license(
1716
kind = "@package_metadata//licenses/spdx:Apache-2.0",
1817
text = "LICENSE",
1918
)
20-
21-
# gazelle:map_kind bzl_library bzl_library @bazel_lib//:bzl_library.bzl
22-
gazelle_binary(
23-
name = "gazelle_bin",
24-
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
25-
)
26-
27-
gazelle(
28-
name = "gazelle",
29-
gazelle = "gazelle_bin",
30-
)

BUILD.dev.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Development-only build targets (gazelle, etc)"""
2+
3+
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
4+
5+
# gazelle:map_kind bzl_library bzl_library @bazel_lib//:bzl_library.bzl
6+
gazelle_binary(
7+
name = "gazelle_bin",
8+
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
9+
)
10+
11+
gazelle(
12+
name = "gazelle",
13+
gazelle = "gazelle_bin",
14+
)

MODULE.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ bazel_dep(name = "bazel_lib", version = "3.0.0", dev_dependency = True)
4343
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1", dev_dependency = True)
4444

4545
bazel_dep(name = "bazelrc-preset.bzl", version = "1.6.0")
46+
47+
# FormatJS CLI toolchain
48+
formatjs_cli = use_extension("//formatjs_cli:extensions.bzl", "formatjs_cli")
49+
formatjs_cli.toolchain(version = "0.1.0")
50+
use_repo(
51+
formatjs_cli,
52+
"formatjs_cli_toolchains_darwin_arm64",
53+
"formatjs_cli_toolchains_linux_x64",
54+
)
55+
56+
register_toolchains("@formatjs_cli_toolchains_darwin_arm64//:toolchain")
57+
58+
register_toolchains("@formatjs_cli_toolchains_linux_x64//:toolchain")

MODULE.bazel.lock

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

REPO.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ repo(
55
"//:package_metadata",
66
],
77
)
8+
9+
ignore_directories([
10+
# Examples are separate workspaces
11+
"examples",
12+
# Bazel convenience symlinks
13+
"bazel-bin",
14+
"bazel-out",
15+
"bazel-rules_formatjs",
16+
"bazel-testlogs",
17+
])

0 commit comments

Comments
 (0)