CI #309
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 4 * * *" | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
- name: Install hdf5 library | |
run: sudo apt-get install -y libhdf5-dev | |
egginfo: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install tox | |
run: python -m pip install --upgrade tox | |
- name: egg-info caom2 | |
run: cd caom2 && tox -e egg_info | |
- name: egg-info caom2utils | |
run: cd caom2utils && tox -e egg_info | |
- name: egg-info caom2repo | |
run: cd caom2repo && tox -e egg_info | |
tests: | |
needs: egginfo | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.7","3.8","3.9","3.10", "3.11"] | |
package: [caom2, caom2utils, caom2repo] | |
exclude: | |
# temporary since hdf5 is not working yet | |
- python-version: "3.11" | |
package: caom2utils | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install tox | |
# pytest-runner required to support deprecated Python3.5 | |
run: python -m pip install --upgrade tox pytest-runner | |
- name: Test ${{ matrix.package }} | |
run: | | |
# add py and remove the "." from python-version in order to get the tox_target | |
tox_target=$(echo py${{matrix.python-version}} | sed 's/\.//') | |
echo "Tox target: " $tox_target | |
cd ${{ matrix.package }} && tox -e $tox_target | |
style_n_coverage: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Setup Graphviz | |
uses: ts-graphviz/setup-graphviz@v1 | |
- name: Install tox | |
run: python -m pip install --upgrade tox | |
- name: checkstyle & coverage caom2 | |
run: cd caom2 && tox -e checkstyle && tox -e cov | |
- name: checkstyle & coverage caom2utils | |
run: cd caom2utils && tox -e checkstyle && tox -e cov | |
- name: checkstyle & coverage caom2repo | |
run: cd caom2repo && tox -e checkstyle && tox -e cov | |
- name: Upload coverage to codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
files: ./caom2/coverage.xml,./caom2utils/coverage.xml,./caom2repo/coverage.xml | |
build-n-publish: | |
name: Build and publish to PyPI | |
needs: style_n_coverage | |
runs-on: ubuntu-latest | |
if: contains(github.ref, '=') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Determine the package | |
run: | | |
echo ${GITHUB_REF#refs/*/} | |
echo "repo_name=$(echo ${GITHUB_REF#refs/*/} | awk -F '=' '{print $1}')" >> $GITHUB_ENV | |
echo "repo_version=$(echo ${GITHUB_REF#refs/*/} | awk -F '=' '{print $2}')" >> $GITHUB_ENV | |
- name: Check version is valid | |
run: | | |
echo ${{ env.repo_name }} | |
echo ${{ env.repo_version }} | |
cd ${{ env.repo_name }} || (echo "Invalid release tag. Repo not found: ${{ env.repo_name }}" && exit -1) | |
sed 's/ //g' setup.cfg | grep "^version=${{ env.repo_version }}" || (echo "Version in tag ${{ env.repo_version }} does not match version in setup.cfg" && exit -1) | |
- name: Install dependencies | |
run: | | |
cd ${{ env.repo_name }} | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Build and publish | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_PUBLISH_USER }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_PWORD }} | |
run: | | |
cd ${{ env.repo_name }} | |
python setup.py sdist bdist_wheel | |
twine upload --skip-existing dist/* |