-
Notifications
You must be signed in to change notification settings - Fork 285
138 lines (137 loc) · 5.6 KB
/
build_extension.yml
File metadata and controls
138 lines (137 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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: set jemalloc page size for ARM64 Linux
if: ${{ matrix.arch == 'arm64' && matrix.platform == 'linux' || matrix.arch == 'arm64' && matrix.platform == 'alpine' }}
run: echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> ${{ matrix.github_env }}
- name: set jemalloc page size for ARM64 macOS
if: ${{ matrix.arch == 'arm64' && matrix.platform == 'darwin' }}
run: echo "JEMALLOC_SYS_WITH_LG_PAGE=14" >> ${{ matrix.github_env }}
- 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"