Skip to content

Commit

Permalink
Merge pull request #6 from pluflou/ci-cd-setup
Browse files Browse the repository at this point in the history
Set up CI/CD, tests and pypi/conda builds
  • Loading branch information
pluflou authored Apr 3, 2024
2 parents 29c7266 + 6cd8ae2 commit 23d7d6b
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 21 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy Main
on:
release:
types: [published]
jobs:
deploy-pypi:
runs-on: ubuntu-latest
environment: deployment
permissions:
id-token: write

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

deploy-conda:
runs-on: ubuntu-latest
# sets default shell to remove need for source to run the conda shell
defaults:
run:
shell: bash -l {0}
environment: deployment
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"

# Much better than manual installation, original version Miniconda2-4.7.10-Linux-x86_64.sh is broken
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
activate-environment: ""
miniconda-version: "latest"

- name: Install the Conda Dependencies
run: |
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install -n base conda-libmamba-solver
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .
- name: Build the Anaconda Package
id: condabuild
run: |
conda install anaconda-client
conda config --set anaconda_upload no --set solver libmamba
echo yes | anaconda login --username ${{ secrets.ANACONDA_CLOUD_USERNAME }} --password ${{ secrets.ANACONDA_CLOUD_PASSWORD }}
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT
- name: Upload the Anaconda Package
id: condaload
run: |
anaconda upload -u stanfordcvxgrp /usr/share/miniconda3/conda-bld/noarch/spcqe-${{ steps.condabuild.outputs.gitversion }}-*.tar.bz2
83 changes: 83 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Tests

on:
push:
pull_request:
types: [opened]
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install Dependencies
run: |
sudo python -m pip install --upgrade pip
sudo python -m pip install -e .
- name: Run Unit Tests
run: sudo python -m unittest

test-build-pypi:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo python -m build
test-build-conda:
runs-on: ubuntu-latest
# sets default shell to remove need for source to run the conda shell
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
activate-environment: ""
miniconda-version: "latest"

- name: Install the Conda Dependencies
run: |
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install -n base conda-libmamba-solver
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .
- name: Build the Anaconda Package
id: condabuild
run: |
conda install anaconda-client
conda config --set anaconda_upload no --set solver libmamba
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/spcqe.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

46 changes: 46 additions & 0 deletions conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% set name = "spcqe" %}
{% set version = "0.0.1a0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/spcqe-{{ version }}.tar.gz
sha256: c9300c2274641c58886dfba464031c6e163ea2da87c0542b2dca7805a1448186

build:
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
number: 0

requirements:
host:
- python >=3.9
- setuptools
- wheel
- pip
run:
- python >=3.9
- numpy
- cvxpy
- scikit-learn
- tqdm
- pybind11 # conda build test fails with "cvxpy 1.4.2 requires pybind11, which is not installed."

test:
imports:
- spcqe
commands:
- pip check
requires:
- pip

about:
summary: Smooth periodic consistent quantile estimation
license: BSD-2-Clause
license_file: LICENSE

extra:
recipe-maintainers:
- pluflou
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"] # PEP 508 specifications.
requires = ["setuptools>=64", "wheel"] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "spcqe"
Expand Down

0 comments on commit 23d7d6b

Please sign in to comment.