-
Notifications
You must be signed in to change notification settings - Fork 8
131 lines (127 loc) · 4.29 KB
/
python.yml
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
name: Python
on:
pull_request:
push:
branches: [main]
tags: ["v*.*.*"]
jobs:
build:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
type: [wheel]
include:
- os: ubuntu-latest
python-version: "3.8"
type: sdist
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Fetch Substrait submodule tags
working-directory: substrait
run: |
git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
git describe --dirty --tags
- name: Install latest protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install sdist-only dependencies
if: ${{ matrix.type == 'sdist' }}
uses: dtolnay/rust-toolchain@stable
- name: sdist-only build prep
if: ${{ matrix.type == 'sdist' }}
working-directory: rs
run: cargo check
# ^ this ensures that its build.rs is run, which is all we need. Sadly
# there doesn't seem to be a way to do this that doesn't pull in all
# normal dependencies: https://github.com/rust-lang/cargo/issues/7178
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python build dependencies
run: python3 -m pip install --upgrade pip "maturin>=0.14,<0.15"
- name: Prepare build environment
working-directory: py
run: python3 prepare_build.py populate
- name: Create sdist
if: ${{ matrix.type == 'sdist' }}
uses: PyO3/[email protected]
with:
command: sdist
args: -o dist -m py/Cargo.toml
- name: Build manylinux wheels
if: ${{ matrix.type == 'wheel' && matrix.os == 'ubuntu-latest' }}
uses: PyO3/[email protected]
with:
manylinux: auto
command: build
args: -i ${{ matrix.python-version }} --release -o dist -m py/Cargo.toml
- name: Build Windows wheels
if: ${{ matrix.type == 'wheel' && matrix.os == 'windows-latest' }}
uses: PyO3/[email protected]
with:
command: build
args: --release -o dist -m py/Cargo.toml
- name: Build MacOS wheels
if: ${{ matrix.type == 'wheel' && matrix.os == 'macos-latest' }}
uses: PyO3/[email protected]
with:
command: build
args: --release -o dist --universal2 -m py/Cargo.toml
- name: Install runtime dependencies
run: python3 -m pip install --upgrade protobuf pytest click pyyaml jdot toml
- name: Install generated sdist
if: ${{ matrix.type == 'sdist' }}
run: python3 -m pip install dist/substrait_validator-*.tar.gz
- name: Install generated wheel
if: ${{ matrix.type == 'wheel' }}
run: python3 -m pip install --no-index --find-links=dist substrait-validator
- name: Test
working-directory: py/tests
run: python3 -m pytest
- name: Upload wheels
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [build]
environment: VALIDATOR_RELEASE
steps:
- uses: actions/download-artifact@v4
with:
name: wheels
- name: Publish to GitHub release page
uses: softprops/action-gh-release@v2
with:
files: |
*.whl
*.tar.gz
- name: Publish to PyPI
uses: PyO3/[email protected]
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
fmt-lint:
name: Style & lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1
- name: Black
run: python3 -m black --diff --check .
- name: Flake8
run: python3 -m flake8 .