Merge pull request #62 from lokkju/lokkju/add-wasm #159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| - fix/* | |
| jobs: | |
| clone_vendors: | |
| name: Clone vendors | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| - name: Install tree-sitter cli | |
| run: npm install -g tree-sitter-cli | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install Dependencies | |
| run: uv sync --no-install-project | |
| - name: Clone vendors | |
| run: | | |
| mkdir parsers | |
| uv run --no-sync scripts/clone_vendors.py | |
| - name: Upload Parsers | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: language-parsers | |
| path: parsers | |
| validate: | |
| needs: clone_vendors | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download parsers | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: language-parsers | |
| path: parsers | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install Dependencies | |
| run: uv sync --no-install-project | |
| - name: Load Cached Pre-Commit Dependencies | |
| id: cached-pre-commit-dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit/ | |
| key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Run Linters | |
| run: uv run --no-sync pre-commit run --show-diff-on-failure --color=always --all-files | |
| build-wheel: | |
| name: Build wheel | |
| needs: clone_vendors | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download parsers | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: language-parsers | |
| path: parsers | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install Dependencies | |
| run: uv sync --no-install-project | |
| - name: Set path in environment | |
| run: echo "PROJECT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Cache Build | |
| id: cache-build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist | |
| *.whl | |
| key: ${{ matrix.os }}-build-${{ hashFiles('sources/**/*', 'parsers/**/*', 'setup.py') }} | |
| - name: Build wheel | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| run: uv build --wheel | |
| env: | |
| PROJECT_ROOT: ${{github.workspace}} | |
| - name: Setup MSYS2 GCC build | |
| if: matrix.os == 'windows-latest' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: true | |
| pacboy: python-pip:p gcc:p | |
| - name: Build MSYS2 GCC wheel | |
| if: matrix.os == 'windows-latest' && steps.cache-build.outputs.cache-hit != 'true' | |
| shell: msys2 {0} | |
| run: | | |
| . .venv/Scripts/activate | |
| pip wheel --no-deps . | |
| - name: Upload wheel artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.os }} | |
| path: | | |
| dist/*.whl | |
| *.whl | |
| if-no-files-found: error | |
| test-wheel: | |
| name: Test wheel | |
| needs: build-wheel | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| #os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm] | |
| os: [ubuntu-latest, windows-latest, ubuntu-24.04-arm] | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.os }} | |
| - name: Install wheel | |
| shell: bash | |
| run: | | |
| wheel_file=$(ls dist/*.whl 2>/dev/null | head -n 1) | |
| if [ -z "$wheel_file" ]; then | |
| wheel_file=$(find dist -name "*.whl" -type f | head -n 1) | |
| fi | |
| echo "Installing wheel: $wheel_file" | |
| pip install "$wheel_file" | |
| - name: Install pytest | |
| run: pip install pytest | |
| - name: Test with installed wheel | |
| run: | | |
| mkdir -p /tmp/test_wheel | |
| cp tests/entry_point_test.py /tmp/test_wheel/ | |
| cd /tmp/test_wheel | |
| pytest entry_point_test.py -v | |
| env: | |
| PROJECT_ROOT: ${{ github.workspace }} | |
| # - name: Set up MSYS2 Python | |
| # if: matrix.os == 'windows-latest' | |
| # uses: msys2/setup-msys2@v2 | |
| # with: | |
| # msystem: UCRT64 | |
| # update: true | |
| # pacboy: python-pip:p gcc:p | |
| # | |
| # - name: Install MSYS2 GCC wheel | |
| # if: matrix.os == 'windows-latest' | |
| # shell: msys2 {0} | |
| # run: | | |
| # wheel_file=$(ls *.whl 2>/dev/null | head -n 1) | |
| # if [ -z "$wheel_file" ]; then | |
| # wheel_file=$(find . -name "*.whl" -type f | head -n 1) | |
| # fi | |
| # echo "Installing wheel: $wheel_file" | |
| # pip install "$wheel_file" | |
| # | |
| # - name: Install MSYS2 pytest | |
| # if: matrix.os == 'windows-latest' | |
| # shell: msys2 {0} | |
| # run: pip install pytest | |
| # | |
| # - name: Test with installed MSYS2 wheel | |
| # if: matrix.os == 'windows-latest' | |
| # shell: msys2 {0} | |
| # run: | | |
| # mkdir -p /tmp/test_wheel | |
| # cp tests/entry_point_test.py /tmp/test_wheel/ | |
| # cd /tmp/test_wheel | |
| # pytest entry_point_test.py -v | |
| # env: | |
| # PROJECT_ROOT: ${{ github.workspace }} |