-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (128 loc) · 5.85 KB
/
Copy pathbuild-hogql-parser.yml
File metadata and controls
140 lines (128 loc) · 5.85 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
139
140
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on: https://github.com/PostHog/posthog/blob/master/.github/workflows/build-hogql-parser.yml
name: Build hogql-parser wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/hogql-parser.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-hogql-parser.yml'
- 'docs/packages/hogql-parser.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-hogql-parser.yml'
- 'docs/packages/hogql-parser.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
# PostHog/posthog never tags this package; pin the commit that bumped
# common/hogql_parser/setup.py to 1.3.84 (matches the PyPI sdist). Same
# commit hogql-parser-rs (build-hogql-parser-rs.yml) is pinned to.
HOGQL_PARSER_REF: c30d2736928729ea424b08003c9cea2006b7606b
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: hogql-parser
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build hogql-parser ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
# setup.py builds a plain per-interpreter Extension (no abi3), matching
# upstream's own coverage for this version (cp310-cp313; cp314 support
# landed after 1.3.84).
python: ["cp310", "cp311", "cp312", "cp313"]
env:
HOGQL_PARSER_VERSION: ${{ matrix.version }}
steps:
# common/hogql_parser's checked-in generated ANTLR sources make this a
# self-contained build directory; sparse-checkout skips the rest of the
# multi-GB posthog monorepo (Django app, frontend, ...).
- name: Checkout posthog common/hogql_parser
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: PostHog/posthog
ref: ${{ env.HOGQL_PARSER_REF }}
sparse-checkout: common/hogql_parser
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: '3.12'
activate-environment: true
enable-cache: false
- name: Build wheel
env:
CIBW_ARCHS: riscv64
# Upstream's own [tool.cibuildwheel] `build` list only names macOS and
# manylinux_x86_64/aarch64 identifiers, so it must be overridden here
# rather than relying on cibuildwheel's `--only` to add riscv64 to it.
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# Upstream's own before-all (manylinux_2_28/AlmaLinux 8) installs
# `epel-release` to get a newer `cmake3` - EPEL doesn't exist on
# riscv64 (gotcha 51) and isn't needed anyway, since Rocky 10's
# system `cmake` is already 3.31. Same antlr4-cpp-runtime source
# build otherwise, unchanged from upstream.
CIBW_BEFORE_ALL_LINUX: |
set -ex
dnf install -y unzip cmake curl uuid pkg-config
curl --fail --location https://www.antlr.org/download/antlr4-cpp-runtime-4.13.1-source.zip --output antlr4-source.zip || curl --fail --location https://raw.githubusercontent.com/antlr/website-antlr4/gh-pages/download/antlr4-cpp-runtime-4.13.1-source.zip --output antlr4-source.zip
antlr_known_md5sum="c875c148991aacd043f733827644a76f"
antlr_found_md5sum="$(md5sum antlr4-source.zip | cut -d' ' -f1)"
if [[ "$antlr_known_md5sum" != "$antlr_found_md5sum" ]]; then exit 64; fi
unzip antlr4-source.zip -d antlr4-source && cd antlr4-source
cmake . -DBUILD_TESTING=OFF -DANTLR4_BUILD_TESTS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
DESTDIR=out make install
cp -r out/usr/local/include/antlr4-runtime /usr/include/
cp out/usr/local/lib64/libantlr4-runtime.so* /usr/lib64/
ldconfig
# No CIBW_TEST_COMMAND: upstream's own workflow doesn't test the wheel
# either. `import hogql_parser` eagerly imports `posthog.hogql.ast`
# (the posthog Django app, not on PyPI) at module load, so it can't be
# smoke-tested outside the monorepo it ships alongside - confirmed by
# reproducing the same ModuleNotFoundError against the real PyPI wheel.
run: |
set -euo pipefail
uv pip install --upgrade cibuildwheel
python -m cibuildwheel --output-dir wheelhouse common/hogql_parser
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: hogql-parser-${{ env.HOGQL_PARSER_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: ./wheelhouse/*.whl
if-no-files-found: error
publish:
name: Publish hogql-parser ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: hogql-parser-${{ matrix.version }}-*-manylinux_riscv64