Skip to content

Commit

Permalink
Add support for GitHub Actions
Browse files Browse the repository at this point in the history
Closes pypa#159
  • Loading branch information
mayeut committed Mar 8, 2020
1 parent 9ae2ae4 commit f84e186
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on: [push, pull_request]

jobs:
test:
name: Test cibuildwheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
name: Install Python ${{ matrix.python_version }}
with:
python-version: "3.7"

- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
- name: Install Visual C++ for Python 2.7
if: startsWith(matrix.os, 'windows')
run: |
choco install vcpython27 -f -y
- name: Test cibuildwheel
run: |
python ./bin/run_tests.py
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cibuildwheel

Python wheels are great. Building them across **Mac, Linux, Windows**, on **multiple versions of Python**, is not.

`cibuildwheel` is here to help. `cibuildwheel` runs on your CI server - currently it supports Azure Pipelines, Travis CI, AppVeyor, and CircleCI - and it builds and tests your wheels across all of your platforms.
`cibuildwheel` is here to help. `cibuildwheel` runs on your CI server - currently it supports Azure Pipelines, Travis CI, AppVeyor, GitHub Actions and CircleCI - and it builds and tests your wheels across all of your platforms.


What does it do?
Expand All @@ -35,13 +35,14 @@ What does it do?
Usage
-----

`cibuildwheel` currently works on **Travis CI**, **Azure Pipelines** and **AppVeyor** to build wheels for all three supported platforms (Linux, macOS, Windows). On **CircleCI** Linux and macOS wheels can be built.
`cibuildwheel` currently works on **Travis CI**, **Azure Pipelines**, **AppVeyor** and **GitHub Actions** to build wheels for all three supported platforms (Linux, macOS, Windows). On **CircleCI** Linux and macOS wheels can be built.

| | Linux | macOS | Windows |
|-----------------|-------|-------|---------|
| Azure Pipelines ||||
| Travis CI ||||
| AppVeyor ||||
| GitHub Actions ||||
| CircleCI ||| |

`cibuildwheel` is not intended to run on your development machine. Because it uses system Python from Python.org it will try to install packages globally - not what you expect from a build tool! Instead, isolated CI services like Travis CI, CircleCI, Azure Pipelines and AppVeyor are ideal.
Expand Down
8 changes: 4 additions & 4 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def main():
if args.platform != 'auto':
platform = args.platform
else:
ci = strtobool(os.environ.get('CI', 'false')) or 'BITRISE_BUILD_NUMBER' in os.environ or 'AZURE_HTTP_USER_AGENT' in os.environ
ci = strtobool(os.environ.get('CI', 'false')) or 'BITRISE_BUILD_NUMBER' in os.environ or 'AZURE_HTTP_USER_AGENT' in os.environ or 'GITHUB_WORKFLOW' in os.environ
if not ci:
print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '
'Travis CI, AppVeyor, Azure Pipelines and CircleCI are supported. You can run on your '
'development machine or other CI providers using the --platform argument. Check --help '
'output for more information.',
'Travis CI, AppVeyor, Azure Pipelines, GitHub Actions and CircleCI are supported. You '
'can run on your development machine or other CI providers using the --platform argument. '
'Check --help output for more information.',
file=sys.stderr)
exit(2)
if sys.platform.startswith('linux'):
Expand Down
13 changes: 13 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ AppVeyor will store the built wheels for you - you can access them from the proj

For more info on this config file, check out the [docs](https://www.appveyor.com/docs/).

# GitHub Actions [linux/mac/windows] {: #github-actions}

Using GitHub Actions, you can build all three platforms on the same service. Create a `./github/workflows/build.yml` file in your repo.

> build.yml
```yaml
{% include "../examples/github-minimal.yml" %}
```

Commit this file, enable building of your repo on GitHub Actions, and push.

For more info on this file, check out the [docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions).

> ⚠️ Got an error? Check the [FAQ](faq.md).
<script>
Expand Down
28 changes: 28 additions & 0 deletions examples/github-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on: [push, pull_request]

jobs:
test:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
name: Install Python ${{ matrix.python_version }}
with:
python-version: "3.7"

- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.2.0
- name: Install Visual C++ for Python 2.7
if: startsWith(matrix.os, 'windows')
run: |
choco install vcpython27 -f -y
- name: Build wheel
run: |
python -m cibuildwheel --output-dir wheelhouse
1 change: 1 addition & 0 deletions unit_test/main_tests/main_platform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_unknown_platform_non_ci(monkeypatch, capsys):
monkeypatch.delenv('CI', raising=False)
monkeypatch.delenv('BITRISE_BUILD_NUMBER', raising=False)
monkeypatch.delenv('AZURE_HTTP_USER_AGENT', raising=False)
monkeypatch.delenv('GITHUB_WORKFLOW', raising=False)

with pytest.raises(SystemExit) as exit:
main()
Expand Down

0 comments on commit f84e186

Please sign in to comment.