Skip to content

Install and Test Package #36

Install and Test Package

Install and Test Package #36

Workflow file for this run

name: Install, Test, and Publish Package
on:
push:
branches:
- main # or your default branch
release:
types: [created]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
miniconda-version: "latest"
auto-activate-base: true
- name: Install mamba for faster environment setup
run: conda install -n base -c conda-forge mamba
- name: Cache Conda Environment
id: cache-conda
uses: actions/cache@v3
with:
path: /Users/runner/miniconda3/envs/ql
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles('environment.yml') }}
restore-keys: |
${{ runner.os }}-conda-${{ matrix.python-version }}-
- name: Remove existing Conda environment if cache not hit
if: steps.cache-conda.outputs.cache-hit != 'true'
run: conda env remove -n ql || echo "Environment does not exist"
- name: Create Conda environment using mamba
if: steps.cache-conda.outputs.cache-hit != 'true'
run: mamba env create -f environment.yml
- name: Install pip dependencies
shell: bash -l {0}
run: |
conda activate ql
pip install -r requirements.txt
- name: Install the package in editable mode
shell: bash -l {0}
run: |
conda activate ql
pip install -e .
- name: Test with pytest
shell: bash -l {0}
run: |
conda activate ql
pytest
publish:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*