Migrate from Travis CI to Github Actions

This commit is contained in:
David Hewitt 2020-08-11 22:32:59 +01:00
parent 565e36d989
commit 51111dc861
10 changed files with 76 additions and 183 deletions

View file

@ -1,4 +1,4 @@
name: Test
name: CI
on: [push, pull_request]
@ -31,11 +31,11 @@ jobs:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }}
strategy:
max-parallel: 12
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, pypy3]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9-dev, pypy3]
platform: [
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
]
@ -48,7 +48,7 @@ jobs:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
@ -59,6 +59,10 @@ jobs:
toolchain: stable
target: ${{ matrix.platform.rust-target }}
- name: Prepare LD_LIBRARY_PATH (Ubuntu only)
if: matrix.platform.os == 'ubuntu-latest'
run: echo ::set-env name=LD_LIBRARY_PATH::${pythonLocation}/lib
- run: rustup set default-host ${{ matrix.platform.rust-target }}
- name: Build without default features
@ -91,3 +95,27 @@ jobs:
env:
RUST_BACKTRACE: 1
coverage:
needs: [fmt]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --features "num-bigint num-complex" --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- uses: actions-rs/grcov@v0.1
id: coverage
- run: echo ${{ steps.coverage.outputs.report }}
- uses: codecov/codecov-action@v1
with:
file: ${{ steps.coverage.outputs.report }}

42
.github/workflows/guide.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: gh-pages
on:
push:
branches:
- master
release:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.1'
# This builds the book in target/guide. See https://github.com/rust-lang-nursery/mdBook/issues/698
- name: Build the guide
run: mdbook build -d ../target/guide guide
# This builds the doc in target/doc
- name: Build the doc
run: |
cargo doc --features="default num-bigint num-complex" --no-deps
echo "<meta http-equiv=refresh content=0;url=pyo3/index.html>" > target/doc/index.html
- name: Prepare tag
id: prepare_tag
run: |
TAG_NAME="${GITHUB_REF##*/}"
echo "::set-output name=tag_name::${TAG_NAME}"
- name: Deploy
uses: peaceiris/actions-gh-pages@v3.7.0-8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/
destination_dir: ${{ steps.prepare_tag.outputs.tag_name }}
full_commit_message: 'Upload documentation for ${{ steps.prepare_tag.outputs.tag_name }}'

View file

@ -1,72 +0,0 @@
language: python
os: linux
dist: bionic
cache:
pip: true
cargo: true
jobs:
include:
- name: Python 3.5
python: "3.5"
- name: Python 3.6
python: "3.6"
- name: Python 3.7
python: "3.7"
- name: Python 3.8
python: "3.8"
- name: Python 3.9-dev
python: "3.9-dev"
- name: Nightly
python: "3.7"
env: TRAVIS_RUST_VERSION=nightly FEATURES="nightly"
- name: Minimum Stable
python: "3.7"
env: TRAVIS_RUST_VERSION=1.39.0
- name: PyPy3.6
python: "pypy3"
env: FEATURES="pypy"
allow_failures:
- python: 3.9-dev
env:
global:
- TRAVIS_RUST_VERSION=stable
- RUST_BACKTRACE=1
before_install:
- source ./ci/travis/setup.sh
- curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf -
install:
- pip install setuptools-rust pytest pytest-benchmark tox
script:
- ./ci/travis/test.sh
deploy:
- provider: script
script: ./ci/travis/cover.sh
edge: true
on:
branch: master
repo: PyO3/pyo3
condition: $TRAVIS_JOB_NAME == "Nightly" && $TRAVIS_EVENT_TYPE != "cron"
- provider: script
script: ./ci/travis/guide.sh
edge: true
on:
branch: master
repo: PyO3/pyo3
condition: $TRAVIS_JOB_NAME == "Python 3.7" && $TRAVIS_EVENT_TYPE != "cron"
- provider: script
script: ./ci/travis/guide.sh
edge: true
on:
tags: true
repo: PyO3/pyo3
condition: $TRAVIS_JOB_NAME == "Python 3.7"
notifications:
email: false

View file

@ -10,14 +10,10 @@ repository = "https://github.com/pyo3/pyo3"
documentation = "https://docs.rs/crate/pyo3/"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
exclude = ["/.gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
exclude = ["/.gitignore", ".cargo/config"]
build = "build.rs"
edition = "2018"
[badges]
travis-ci = { repository = "PyO3/pyo3", branch = "master" }
appveyor = { repository = "fafhrd91/pyo3" }
[dependencies]
ctor = { version = "0.1", optional = true }
indoc = { version = "0.3.4", optional = true }

View file

@ -47,7 +47,7 @@ Here are a few things to note when you are writing PRs.
### Continuous Integration
The PyO3 repo uses a mixture of Github actions and Travis CI. PRs are blocked from merging if CI is not successful.
The PyO3 repo uses Github Actions. PRs are blocked from merging if CI is not successful.
Formatting, linting and tests are checked for all Rust and Python code. Tests run with all supported Python versions with the latest stable Rust compiler, as well as for Python 3.8 with the minimum supported Rust version.

View file

@ -1,6 +1,5 @@
# PyO3
[![Build Status](https://travis-ci.org/PyO3/pyo3.svg?branch=master)](https://travis-ci.org/PyO3/pyo3)
[![Actions Status](https://github.com/PyO3/pyo3/workflows/Test/badge.svg)](https://github.com/PyO3/pyo3/actions)
[![codecov](https://codecov.io/gh/PyO3/pyo3/branch/master/graph/badge.svg)](https://codecov.io/gh/PyO3/pyo3)
[![crates.io](http://meritbadge.herokuapp.com/pyo3)](https://crates.io/crates/pyo3)

View file

@ -1,14 +0,0 @@
#!/bin/bash
set -ex
### Run grcov ##################################################################
# export env vars and re-run tests
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zpanic_abort_tests -Zprofile -Cpanic=abort -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off"
export RUSTDOCFLAGS="-Cpanic=abort"
cargo test --features "$FEATURES num-bigint num-complex"
zip -0 ccov.zip `find . \( -name "pyo3*.gc*" \) -print`;
./grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info;
bash <(curl -s https://codecov.io/bash) -f lcov.info;

View file

@ -1,45 +0,0 @@
#!/bin/bash
set -ex
### Setup latest mdbook version ################################################
INSTALLED=$(echo $(mdbook --version 2>/dev/null || echo "mdbook none") | cut -d' ' -f1)
PINNED=0.4.0
if [ "$PINNED" != "$INSTALLED" ]; then
URL=https://github.com/rust-lang-nursery/mdBook/releases/download/v${PINNED}/mdbook-v${PINNED}-x86_64-unknown-linux-gnu.tar.gz
curl -SsL $URL | tar xvz -C $HOME/.cargo/bin
fi
### Build the guide ################################################################
# Build and then upload the guide to a specific folder on the gh-pages branch. This way we can have multiple versions
# of the guide at the same time (See #165)
# This builds the book in target/guide. See https://github.com/rust-lang-nursery/mdBook/issues/698
mdbook build -d ../target/guide guide
# Build the doc
# This builds the book in target/doc
cargo doc --features="default num-bigint num-complex" --no-deps
echo "<meta http-equiv=refresh content=0;url=pyo3/index.html>" > target/doc/index.html
# Get the lastest tag across all branches
git fetch --tags
LASTEST_TAG=$(git tag -l --points-at $(git rev-list --tags --max-count=1))
git clone -b gh-pages https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh_pages
cd gh_pages
echo "<meta http-equiv=refresh content=0;url='${LASTEST_TAG}/'>" > index.html
echo "pyo3.rs" > CNAME
# For builds triggered by a tag, $TRAVIS_BRANCH will be set to the tag
rm -rf "$TRAVIS_BRANCH"
cp -r ../target/guide "$TRAVIS_BRANCH"
cp -r ../target/doc "$TRAVIS_BRANCH"
git add --all
if git commit -m "Upload documentation for $TRAVIS_BRANCH"; then
git push -f
fi

View file

@ -1,20 +0,0 @@
#!/bin/bash
set -e
### Setup Rust toolchain #######################################################
# Use profile=minimal here to skip installing clippy
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$TRAVIS_RUST_VERSION --profile=minimal -y
export PATH=$PATH:$HOME/.cargo/bin
if [[ $RUN_LINT == 1 ]]; then
rustup component add clippy
rustup component add rustfmt
fi
### Setup python linker flags ##################################################
PYTHON_LIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib"
echo ${LD_LIBRARY_PATH}

View file

@ -1,21 +0,0 @@
#!/bin/bash
set -ex
# run `cargo test` only if testing against cpython.
if ! [[ $FEATURES == *"pypy"* ]]; then
cargo test --features "$FEATURES num-bigint num-complex"
( cd pyo3-derive-backend; cargo test )
else
# check that pypy at least builds
cargo build;
fi
for example_dir in examples/*; do
cd $example_dir
if [[ $FEATURES == *"pypy"* ]]; then
tox -c "tox.ini" -e pypy3
else
tox -c "tox.ini" -e py
fi
cd -
done