CI #1344
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@v4 | |
egginfo: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
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.8","3.9","3.10","3.11","3.12"] | |
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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install tox | |
run: python -m pip install --upgrade tox | |
- 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@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Setup Graphviz | |
uses: ts-graphviz/setup-graphviz@v2 | |
- 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@v4 | |
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 | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
if: contains(github.ref, '=') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
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 | |
- name: Install package | |
run: | | |
cd ${{ env.repo_name }} | |
python setup.py sdist bdist_wheel | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: ${{ env.repo_name }}/dist/ |