Refactor IsInstancePattern to use NarrowSource on IsInstance #3829
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: build_extension | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| push: | |
| paths: | |
| - '**/*' | |
| - '!.*' | |
| - '.github/workflows/build_extension.yml' | |
| jobs: | |
| get_version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pyrefly_version: ${{ steps.pyrefly-version.outputs.PYREFLY_VERSION }} | |
| steps: | |
| - name: Checkout repo (to see version.bzl in next step) | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Get all history for all branches and tags | |
| - name: Get version | |
| id: pyrefly-version | |
| run: | | |
| # setting to variable is necessary so sed failures will be red | |
| VERSION=$(sed -n -e 's/^VERSION = "\(.*\)"/\1/p' version.bzl) | |
| echo "PYREFLY_VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| build_extension: | |
| needs: get_version | |
| if: ${{ success() }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| platform: win32 | |
| arch: x64 | |
| github_env: $env:GITHUB_ENV | |
| - os: windows-latest | |
| platform: win32 | |
| arch: arm64 | |
| github_env: $env:GITHUB_ENV | |
| - os: ubuntu-latest | |
| platform: linux | |
| arch: x64 | |
| rust_target: x86_64-unknown-linux-musl | |
| github_env: $GITHUB_ENV | |
| - os: ubuntu-24.04-arm | |
| platform: linux | |
| arch: arm64 | |
| # necessary for glibc 2.31 | |
| container: ubuntu:20.04 | |
| github_env: $GITHUB_ENV | |
| - os: ubuntu-24.04-arm | |
| platform: linux | |
| arch: armhf | |
| # necessary for glibc 2.31 | |
| container: ubuntu:20.04 | |
| github_env: $GITHUB_ENV | |
| - os: ubuntu-latest | |
| platform: alpine | |
| arch: x64 | |
| rust_target: x86_64-unknown-linux-musl | |
| github_env: $GITHUB_ENV | |
| - os: ubuntu-24.04-arm | |
| platform: alpine | |
| arch: arm64 | |
| # necessary for glibc 2.31 | |
| container: ubuntu:20.04 | |
| github_env: $GITHUB_ENV | |
| # x86 EOL on github-actions is august 2027 according to https://github.com/actions/runner-images/issues/13046 | |
| # we are currently cross-compiling but still running on macos-15-intel for the e2e tests. at EOL, we | |
| # likely need to disable the e2e test for this platform (e2e test tries starting binary on the machine). | |
| - os: macos-15-intel | |
| platform: darwin | |
| arch: x64 | |
| rust_target: x86_64-apple-darwin | |
| github_env: $GITHUB_ENV | |
| - os: macos-14 | |
| platform: darwin | |
| arch: arm64 | |
| github_env: $GITHUB_ENV | |
| runs-on: ${{ matrix.os }} | |
| container: ${{ matrix.container }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Read rust-toolchain file | |
| # matrix.github_env is necessary to differentiate between windows and linux environment variables | |
| # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#environment-files | |
| # https://stackoverflow.com/questions/66733076/github-actions-set-environment-variable-for-windows-build-with-powershell | |
| run: echo "toolchain=$(cat pyrefly/rust-toolchain)" && echo "toolchain=$(cat pyrefly/rust-toolchain)" >> ${{ matrix.github_env }} | |
| - name: install toolchain dependencies | |
| if: ${{ matrix.container == 'ubuntu:20.04' }} | |
| shell: bash | |
| run: | | |
| apt-get update && apt-get -y install curl build-essential | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ env.toolchain }} | |
| - name: set windows cargo home | |
| # we need to set CARGO_HOME to a high-up directory on Windows machines, since some dependencies cloned | |
| # by Cargo have long paths and will cause builds/tests to fail | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: echo "CARGO_HOME=C:\\cargo" >> ${{ matrix.github_env }} | |
| - name: set up rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: pyrefly-extension | |
| - name: build pyrefly binary (cross-compile) | |
| if: ${{ matrix.rust_target != '' }} | |
| uses: houseabsolute/actions-rust-cross@v1 | |
| with: | |
| command: build | |
| target: ${{ matrix.rust_target }} | |
| args: "--release --all-features --artifact-dir lsp/bin --manifest-path pyrefly/Cargo.toml -Z unstable-options" | |
| toolchain: ${{ env.toolchain }} | |
| - name: build pyrefly binary | |
| if: ${{ matrix.rust_target == '' }} | |
| run: cargo build --release --all-features --artifact-dir lsp/bin --manifest-path pyrefly/Cargo.toml -Z unstable-options | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: save platform name | |
| run: echo "platform=${{ matrix.platform }}-${{ matrix.arch }}" >> ${{ matrix.github_env }} | |
| - run: npm ci | |
| working-directory: lsp/ | |
| - run: npx vsce package --target ${{ env.platform }} ${{needs.get_version.outputs.pyrefly_version}} | |
| working-directory: lsp/ | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: pyrefly-${{ env.platform }} | |
| path: "lsp/*.vsix" |