Merge pull request #428 from lsst/tickets/SP-1685 #209
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: Run CI | |
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: Miniforge3 | |
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 | |
- name: install rubin_sim | |
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 data if needed | |
shell: bash -l {0} | |
run: | | |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data | |
scheduler_download_data --tdqm_disable --update | |
rs_download_testing | |
- name: conda list | |
shell: bash -l {0} | |
run: conda list | |
- name: run black | |
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_sim --cov=tests --cov-report=xml --cov-report=term --cov-branch | |
- name: Upload coverage to codecov | |
uses: codecov/codecov-action@v4 | |
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@v5 | |
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 }} |