Skip to content

Commit ddc8311

Browse files
committed
Minimize builds
1 parent 48828c8 commit ddc8311

File tree

2 files changed

+230
-0
lines changed

2 files changed

+230
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CodeQL
2+
on:
3+
schedule:
4+
# every day at midnight
5+
- cron: "0 0 * * *"
6+
7+
concurrency:
8+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
analyze:
13+
runs-on: ubuntu-22.04
14+
permissions:
15+
actions: read
16+
contents: read
17+
security-events: write
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
language:
23+
- python
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: github/codeql-action/init@v2
28+
with:
29+
languages: ${{ matrix.language }}
30+
- uses: github/codeql-action/autobuild@v2
31+
- uses: github/codeql-action/analyze@v2

.github/workflows/wheels.yml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Workflow to build wheels for upload to PyPI.
2+
# Inspired by numpy's cibuildwheel config https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml
3+
#
4+
# In an attempt to save CI resources, wheel builds do
5+
# not run on each push but only weekly and for releases.
6+
# Wheel builds can be triggered from the Actions page
7+
# (if you have the perms) on a commit to master.
8+
#
9+
# Alternatively, you can add labels to the pull request in order to trigger wheel
10+
# builds.
11+
# The label(s) that trigger builds are:
12+
# - Build
13+
name: Wheel builder
14+
15+
on:
16+
schedule:
17+
# ┌───────────── minute (0 - 59)
18+
# │ ┌───────────── hour (0 - 23)
19+
# │ │ ┌───────────── day of the month (1 - 31)
20+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
21+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
22+
# │ │ │ │ │
23+
- cron: "27 3 */1 * *"
24+
push:
25+
pull_request:
26+
types: [labeled, opened, synchronize, reopened]
27+
workflow_dispatch:
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
build_wheels:
35+
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
36+
if: >-
37+
github.event_name == 'schedule' ||
38+
github.event_name == 'workflow_dispatch' ||
39+
(github.event_name == 'pull_request' &&
40+
contains(github.event.pull_request.labels.*.name, 'Build')) ||
41+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
42+
runs-on: ${{ matrix.buildplat[0] }}
43+
strategy:
44+
# Ensure that a wheel builder finishes even if another fails
45+
fail-fast: false
46+
matrix:
47+
# GitHub Actions doesn't support pairing matrix values together, let's improvise
48+
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
49+
buildplat:
50+
- [ubuntu-20.04, manylinux_x86_64]
51+
- [macos-11, macosx_*]
52+
- [windows-2019, win_amd64]
53+
- [windows-2019, win32]
54+
# TODO: support PyPy?
55+
python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"]]# "pp38", "pp39"]
56+
env:
57+
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
58+
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
59+
steps:
60+
- name: Checkout pandas
61+
uses: actions/checkout@v3
62+
with:
63+
submodules: true
64+
# versioneer.py requires the latest tag to be reachable. Here we
65+
# fetch the complete history to get access to the tags.
66+
# A shallow clone can work when the following issue is resolved:
67+
# https://github.com/actions/checkout/issues/338
68+
fetch-depth: 0
69+
70+
- name: Build wheels
71+
uses: pypa/cibuildwheel@v2.9.0
72+
env:
73+
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
74+
75+
# Used to test(Windows-only) and push the built wheels
76+
# You might need to use setup-python separately
77+
# if the new Python-dev version
78+
# is unavailable on conda-forge.
79+
- uses: conda-incubator/setup-miniconda@v2
80+
with:
81+
auto-update-conda: true
82+
python-version: ${{ matrix.python[1] }}
83+
activate-environment: test
84+
channels: conda-forge, anaconda
85+
channel-priority: true
86+
mamba-version: "*"
87+
88+
- name: Test wheels (Windows 64-bit only)
89+
if: ${{ matrix.buildplat[1] == 'win_amd64' }}
90+
shell: cmd /C CALL {0}
91+
run: |
92+
python ci/test_wheels.py wheelhouse
93+
94+
- uses: actions/upload-artifact@v3
95+
with:
96+
name: ${{ matrix.python[0] }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
97+
path: ./wheelhouse/*.whl
98+
99+
100+
- name: Install anaconda client
101+
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
102+
shell: bash -el {0}
103+
run: conda install -q -y anaconda-client
104+
105+
106+
- name: Upload wheels
107+
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
108+
shell: bash -el {0}
109+
env:
110+
PANDAS_STAGING_UPLOAD_TOKEN: ${{ secrets.PANDAS_STAGING_UPLOAD_TOKEN }}
111+
PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }}
112+
run: |
113+
source ci/upload_wheels.sh
114+
set_upload_vars
115+
# trigger an upload to
116+
# https://anaconda.org/scipy-wheels-nightly/pandas
117+
# for cron jobs or "Run workflow" (restricted to main branch).
118+
# Tags will upload to
119+
# https://anaconda.org/multibuild-wheels-staging/pandas
120+
# The tokens were originally generated at anaconda.org
121+
upload_wheels
122+
build_sdist:
123+
name: Build sdist
124+
if: >-
125+
github.event_name == 'schedule' ||
126+
github.event_name == 'workflow_dispatch' ||
127+
(github.event_name == 'pull_request' &&
128+
contains(github.event.pull_request.labels.*.name, 'Build')) ||
129+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
130+
runs-on: ubuntu-22.04
131+
env:
132+
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
133+
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
134+
steps:
135+
- name: Checkout pandas
136+
uses: actions/checkout@v3
137+
with:
138+
submodules: true
139+
# versioneer.py requires the latest tag to be reachable. Here we
140+
# fetch the complete history to get access to the tags.
141+
# A shallow clone can work when the following issue is resolved:
142+
# https://github.com/actions/checkout/issues/338
143+
fetch-depth: 0
144+
145+
# Used to push the built sdist
146+
- uses: conda-incubator/setup-miniconda@v2
147+
with:
148+
auto-update-conda: true
149+
# Really doesn't matter what version we upload with
150+
# just the version we test with
151+
python-version: '3.8'
152+
channels: conda-forge
153+
channel-priority: true
154+
mamba-version: "*"
155+
156+
- name: Build sdist
157+
run: |
158+
pip install build
159+
python -m build --sdist
160+
- name: Test the sdist
161+
shell: bash -el {0}
162+
run: |
163+
# TODO: Don't run test suite, and instead build wheels from sdist
164+
# by splitting the wheel builders into a two stage job
165+
# (1. Generate sdist 2. Build wheels from sdist)
166+
# This tests the sdists, and saves some build time
167+
python -m pip install dist/*.gz
168+
pip install hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-asyncio>=0.17
169+
cd .. # Not a good idea to test within the src tree
170+
python -c "import pandas; print(pandas.__version__);
171+
pandas.test(extra_args=['-m not clipboard and not single_cpu', '--skip-slow', '--skip-network', '--skip-db', '-n=2']);
172+
pandas.test(extra_args=['-m not clipboard and single_cpu', '--skip-slow', '--skip-network', '--skip-db'])"
173+
- uses: actions/upload-artifact@v3
174+
with:
175+
name: sdist
176+
path: ./dist/*
177+
178+
- name: Install anaconda client
179+
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
180+
shell: bash -el {0}
181+
run: |
182+
conda install -q -y anaconda-client
183+
184+
- name: Upload sdist
185+
if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }}
186+
shell: bash -el {0}
187+
env:
188+
PANDAS_STAGING_UPLOAD_TOKEN: ${{ secrets.PANDAS_STAGING_UPLOAD_TOKEN }}
189+
PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }}
190+
run: |
191+
source ci/upload_wheels.sh
192+
set_upload_vars
193+
# trigger an upload to
194+
# https://anaconda.org/scipy-wheels-nightly/pandas
195+
# for cron jobs or "Run workflow" (restricted to main branch).
196+
# Tags will upload to
197+
# https://anaconda.org/multibuild-wheels-staging/pandas
198+
# The tokens were originally generated at anaconda.org
199+
upload_wheels

0 commit comments

Comments
 (0)