Skip to content

Commit

Permalink
ci: added github workflow and setup file
Browse files Browse the repository at this point in the history
  • Loading branch information
rabii-chaarani committed Jul 3, 2024
1 parent 910fa50 commit 64f9437
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 0 deletions.
154 changes: 154 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
on: [push, pull_request]
name: release-please
jobs:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black ruff
- name: Autoformat with black
run: |
black .
- name: Lint with ruff
run: |
ruff check LoopDataConverter --fix
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: style fixes by ruff and autoformatting by black"

continuous-integration:
name: Continuous integration ${{ matrix.os }} python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(vars.BUILD_OS)}}
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3

with:
python-version: ${{ matrix.python-version }}
- name: Installing dependencies
shell: bash -l {0}
run: |
conda install -c conda-forge -c loop3d numpy scipy pytest matplotlib mplstereonet ipywidgets loopstructural -y
- name: Building and install
shell: bash -l {0}
run: |
pip install . --user
- name: pytest
shell: bash -l {0}
run: |
pytest
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
release-type: python
package-name: LoopDataConverter
version-file: LoopDataConverter/version.py
outputs:
release_created: ${{ steps.release.outputs.release_created }}
# if a release is created then run the deploy scripts for github.io, conda, pypi and docker

conda-deploy:
name: Building conda package for python ${{ matrix.os }})
needs: "continuous-integration"
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v4
- name: update submodules
# shell: bash -l {0}
run: |
git submodule update --init --recursive
- name: Conda build
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
shell: bash -l {0}
run: |
conda install -c conda-forge -c loop3d conda-build numpy scipy loopstructural anaconda-client -y
conda build -c anaconda -c conda-forge -c loop3d --output-folder conda conda
conda convert -p all conda/linux-64/*.tar.bz2 -f -o conda
conda install anaconda-client -y
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: conda-${{ matrix.os }}-${{ matrix.python-version }}
path: conda

make_sdist:
needs: "continuous-integration"
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build SDist
run: |
pip install build
python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

upload_to_conda:
needs: ["release-please", "conda-deploy"]
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/download-artifact@v4
with:
name: conda-${{ matrix.os }}-${{ matrix.python-version }}
path: conda
- uses: conda-incubator/setup-miniconda@v3
- name: upload all files to conda-forge
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda install -c anaconda anaconda-client -y
anaconda upload --label main conda/*/*.tar.bz2
upload_to_pypi:
needs: ["release-please", "conda-deploy"]
runs-on: "ubuntu-latest"

if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
verbose: true
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions LoopDataConverter/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0-beta.0"
1 change: 1 addition & 0 deletions conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

43 changes: 43 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% set name = "loopdataconverter" %}

package:
name: "{{ name|lower }}"
version: "{{ environ.get('GIT_DESCRIBE_TAG', '') }}"

source:
git_url: https://github.com/Loop3D/LoopDataConverter

build:
number: 0
script: "{{ PYTHON }} -m pip install ."

requirements:
build:
- {{ compiler('cxx') }}
- numpy
host:
- pip
- python
- setuptools
- numpy
run:
- numpy
- python>=3.9
test:
import:
- numpy
- pandas


about:
home: "https://github.com/Loop3D/LoopDataConverter"
license: MIT
license_family: MIT
license_file:
summary: "Automatic conversion library of geological data (GIS) into Map2Loop and LoopStructural"
doc_url: "https://loop3d.github.io/LoopDataConverter/"
dev_url:

extra:
recipe-maintainers:
- rabii-chaarani
52 changes: 52 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import codecs
from setuptools import setup, find_packages
import os

package_root = os.path.abspath(os.path.dirname(__file__))

version = {}
with open(os.path.join(package_root, "FoldOptLib/version.py")) as fp:
exec(fp.read(), version)
version = version["__version__"]

setup(
name="LoopDataConverter",
install_requires=[
"loopstructural>=1.4.10",
"ipywidgets",
"mplstereonet",
"scipy>=1.11.3", # 1.11.3 is required to use vonmises_fisher() in scipy.stats
"dill",
"beartype",
],
python_requires=">=3.9",
description="Open source Fold Geometry Optimisers for LoopStructural and Map2Loop",
long_description=codecs.open("README.md", "r", "utf-8").read(),
author="Rabii Chaarani",
author_email="[email protected]",
license=("MIT"),
url="https://github.com/Loop3D/FoldOptLib",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Other Audience",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"License :: Free for non-commercial use",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Multimedia :: Graphics :: 3D Modeling",
"Topic :: Scientific/Engineering",
],
version=version,
packages=find_packages(),
keywords=[
"earth sciences",
"geology",
"3-D modelling",
"structural geology",
"uncertainty",
"fold geometry",
],
)

0 comments on commit 64f9437

Please sign in to comment.