Skip to content

Add Rust binding to README.md #1760

Add Rust binding to README.md

Add Rust binding to README.md #1760

Workflow file for this run

name: Bazel
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
resource-package:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Compute version
id: version
shell: bash
run: |
VERSION=$(bash scripts/compute-version.sh)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Computed version: $VERSION"
- uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
repository-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Configure BuildBuddy
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
shell: bash
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
if [ -n "${BUILDBUDDY_API_KEY}" ]; then
{
echo "build --config=buildbuddy"
echo "build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
echo "build --bes_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
} >> .bazelrc.user
echo "BuildBuddy enabled."
else
echo "BUILDBUDDY_API_KEY not set; skipping BuildBuddy config."
fi
- name: Build resource package
shell: bash
env:
MSYS_NO_PATHCONV: 1
run: |
bazel build \
--workspace_status_command=./scripts/bazel-workspace-status.sh \
//data:opencc_resources_zip
- name: Stage resource package
shell: bash
run: |
mkdir -p dist
cp bazel-bin/data/opencc-resources.zip "dist/opencc-${VERSION}-resources.zip"
unzip -l "dist/opencc-${VERSION}-resources.zip"
- name: Upload resource package
uses: actions/upload-artifact@v7
with:
path: dist/opencc-${{ env.VERSION }}-resources.zip
archive: false
if-no-files-found: error
build-and-test:
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-2025-vs2026]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Best-effort Defender exclusions
if: runner.os == 'Windows'
shell: pwsh
continue-on-error: true
run: |
Add-MpPreference -ExclusionPath "$env:GITHUB_WORKSPACE" `
-ExclusionProcess "bazel.exe","bazelisk.exe","python.exe","cl.exe","link.exe"
- name: Compute version
id: version
shell: bash
run: |
VERSION=$(bash scripts/compute-version.sh)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Computed version: $VERSION"
- uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
repository-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Configure BuildBuddy
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && runner.os != 'Windows'
shell: bash
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
if [ -n "${BUILDBUDDY_API_KEY}" ]; then
{
echo "build --config=buildbuddy"
echo "build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
echo "build --bes_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
} >> .bazelrc.user
echo "BuildBuddy enabled."
else
echo "BUILDBUDDY_API_KEY not set; skipping BuildBuddy config."
fi
- name: Build
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
env:
MSYS_NO_PATHCONV: 1
run: bazel build //:opencc //src/tools/... //plugins/... //node/...
- name: Test
shell: bash
env:
MSYS_NO_PATHCONV: 1
run: |
set +e
bazel test --show_timestamps --test_output=all --nocache_test_results --skip_incompatible_explicit_targets //src/... //data/... //test/... //python/... //plugins/... //node/test:node_test
status=$?
bash scripts/collect_bazel_testlogs.sh bazel-testlogs-artifact
if [ "$status" -ne 0 ]; then
echo "Bazel test failed with exit code ${status}."
testlogs_dir="$(bazel info bazel-testlogs 2>/dev/null)"
echo "Bazel testlogs dir: ${testlogs_dir}"
echo "Failing test logs:"
find "${testlogs_dir}" -name test.log -print
while IFS= read -r log; do
echo "===== ${log#"${testlogs_dir}/"} ====="
sed -n '1,240p' "${log}"
done < <(find "${testlogs_dir}" -name test.log -print | sort)
fi
exit "$status"
- name: upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: opencc-${{ env.VERSION }}-bazel-${{ matrix.os }}
path: |
bazel-testlogs-artifact/**