name: CI for Linux
# https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md

# Run on push.
on: push

permissions:
  contents: read

# Prevent previous workflows from running.
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  build:
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
    runs-on: ubuntu-24.04
    timeout-minutes: 60

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          submodules: recursive
          persist-credentials: false

      - name: Setup
        run: |
          sudo apt-get update
          sudo apt-get install -y libibus-1.0-dev qt6-base-dev
          #
          # Unset the Android NDK setting to skip the unnecessary configuration.
          echo "ANDROID_NDK_HOME=" >> $GITHUB_ENV

      - name: bazel build
        working-directory: ./src
        run: |
          bazelisk build --config oss_linux package --config release_build

      - name: Upload Artifacts
        uses: actions/upload-artifact@v6
        with:
          name: mozc.zip
          path: src/bazel-bin/unix/mozc.zip
          if-no-files-found: warn

  test:
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
    runs-on: ubuntu-24.04
    timeout-minutes: 60

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          submodules: recursive
          persist-credentials: false

      - name: Setup
        run: |
          sudo apt-get update
          sudo apt-get install -y libibus-1.0-dev qt6-base-dev
          #
          # Unset the Android NDK setting to skip the unnecessary configuration.
          echo "ANDROID_NDK_HOME=" >> $GITHUB_ENV

      - name: bazel test
        working-directory: ./src
        run: |
          bazelisk test ... --config oss_linux -c dbg
