Skip to content

Merge pull request #65 from hombit/cibuildwheel #1

Merge pull request #65 from hombit/cibuildwheel

Merge pull request #65 from hombit/cibuildwheel #1

name: Python package
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Linux, Python 3.8
os: ubuntu-latest
python-version: 3.8
toxenv: py38-test
gfortran-version: 9
- name: Linux, Python 3.9
os: ubuntu-22.04
python-version: 3.9
toxenv: py39-test
gfortran-version: 11
- name: macOS, Python 3.8
os: macOS-11
python-version: 3.8
toxenv: py38-test
gfortran-version: 10
- name: macOS, Python 3.10, coverage
os: macOS-11
python-version: "3.10"
# Include at least one coverage option for codecov.
toxenv: py310-test-cov
gfortran-version: 11
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- if: runner.os == 'macOS'
name: macOS gfortran
run: |
sudo ln -s /usr/local/bin/gfortran-${{ matrix.gfortran-version }} /usr/local/bin/gfortran
sudo mkdir /usr/local/gfortran
sudo ln -s /usr/local/Cellar/gcc@${{ matrix.gfortran-version }}/*/lib/gcc/${{ matrix.gfortran-version }} /usr/local/gfortran/lib
- if: runner.os == 'Linux'
name: ubuntu gfortran
run: sudo ln -sf /usr/bin/gfortran-${{ matrix.gfortran-version }} /usr/bin/gfortran
- name: Check gfortran version
run: gfortran --version
- name: Install Tox and any other packages
run: |
pip install numpy
pip install tox
- name: Run tests with remote
run: |
mkdir ./.tmp
mkdir ./.tmp/${{ matrix. toxenv }}
tox -e ${{ matrix.toxenv }} -- --remote-data
- name: Run documentation
run: tox -e build_docs
- name: Upload coverage to codecov
if: ${{ contains(matrix.toxenv,'-cov') }}
uses: codecov/codecov-action@v2
with:
file: ./.tox/coverage.xml
build_docs_job:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Tox and any other packages
run: |
sudo ln -sf /usr/bin/gfortran-9 /usr/bin/gfortran
pip install numpy
pip install tox
- name: Run documentation
run: tox -e build_docs
- name: Execute script to build our documentation and update pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd docs
#######################
# Update GitHub Pages #
#######################
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
docroot=`mktemp -d`
rsync -av "_build/html/" "${docroot}/"
pushd "${docroot}"
# don't bother maintaining history; just generate fresh
git init
git remote add deploy "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b gh-pages
# add .nojekyll to the root so that github won't 404 on content added to dirs
# that start with an underscore (_), such as our "_content" dir..
touch .nojekyll
# Add README
cat > README.md <<EOF
# GitHub Pages Cache
Nothing to see here. The contents of this branch are essentially a cache that's not intended to be viewed on github.com.
If you're looking to update our documentation, check the relevant development branch's 'docs/' dir.
EOF
# copy the resulting html pages built from sphinx above to our new git repo
git add .
# commit all the new files
msg="Updating github pages documentation"
git commit -am "${msg}"
# overwrite the contents of the gh-pages branch on our github.com repo
git push deploy gh-pages --force
popd # return to main repo sandbox root
# exit cleanly
exit 0
shell: bash