Skip to content

Merge pull request #79 from lsst/u/yoachim/euclid_detailer_clean #317

Merge pull request #79 from lsst/u/yoachim/euclid_detailer_clean

Merge pull request #79 from lsst/u/yoachim/euclid_detailer_clean #317

name: Run Tests and Publish PyPI
on:
# Trigger the workflow on push (to main) or pull request
push:
tags:
- "*"
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:
jobs:
tests:
name: Run Unit Tests (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
channels: conda-forge,defaults
use-mamba: true
channel-priority: strict
show-channel-urls: true
- name: configure conda and install requirements
shell: bash -l {0}
run: |
mamba install --quiet --file=requirements.txt
mamba install --quiet --file=test-requirements.txt
pip install lsst.resources
- name: install rubin_scheduler
shell: bash -l {0}
run: |
echo `pwd`
ls ${{ github.workspace }}
python -m pip install -e . --no-deps
- name: Access rubin-sim-data cache
id: cache-rs
uses: actions/cache@v4
env:
cache-name: cached-rubin-sim-data
with:
path: ~/rubin_sim_data
key: ${{ env.cache-name }}
restore-keys: |
${{ env.cache-name }}
- name: Update rubin-sim-data if needed
shell: bash -l {0}
run: |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
# Download anything that is not current
scheduler_download_data --tdqm_disable --update
- name: conda list
shell: bash -l {0}
run: conda list
- name: black format test
shell: bash -l {0}
run: black --check .
- name: run tests
shell: bash -l {0}
run: |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
pytest -r a -v --cov=rubin_scheduler --cov=tests --cov-report=xml --cov-report=term --cov-branch
- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
with:
file: coverage.xml
pypi:
name: Build and Publish to PyPI
runs-on: ubuntu-latest
needs: [tests]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
# Need to clone everything to embed the version.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "pip"
- name: Install dependencies for build
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools build
- name: Build and create distribution
run: |
python -m build --skip-dependency-check
- name: Upload to lsst-sp PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.SP_PYPI_UPLOADS }}