Skip to content

Commit

Permalink
Merge pull request #35 from OpenBioSim/fix_ci
Browse files Browse the repository at this point in the history
Update CI for new release process on main
  • Loading branch information
lohedges authored Apr 14, 2023
2 parents df133ed + 52d8d0c commit 083dc3e
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 50 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/devel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release Devel

on:
workflow_dispatch:
push:
branches: [ devel ]

jobs:
build:
name: build (${{ matrix.python-version }}, ${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
strategy:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
platform:
- { name: "windows", os: "windows-latest", shell: "pwsh" }
- { name: "linux", os: "ubuntu-latest", shell: "bash -l {0}" }
- { name: "macos", os: "macos-latest", shell: "bash -l {0}" }
exclude:
# Exclude all but the latest Python from all but Linux
- platform:
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
python-version: "3.8"
- platform: { name: "windows", os: "windows-latest", shell: "pwsh" }
python-version: "3.8"
- platform:
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
python-version: "3.9"
- platform: { name: "windows", os: "windows-latest", shell: "pwsh" }
python-version: "3.9"
environment:
name: biosimspace-build
defaults:
run:
shell: ${{ matrix.platform.shell }}
env:
SIRE_DONT_PHONEHOME: 1
SIRE_SILENT_PHONEHOME: 1
steps:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: bss_build
miniforge-version: latest
miniforge-variant: Mambaforge
use-mamba: true
#
- name: Clone the devel branch
run: git clone -b devel https://github.com/openbiosim/biosimspace
#
- name: Setup Conda
run: mamba install -y -c conda-forge boa anaconda-client packaging=21 pip-requirements-parser
#
- name: Update Conda recipe
run: python ${{ github.workspace }}/biosimspace/actions/update_recipe.py
#
- name: Prepare build location
run: mkdir ${{ github.workspace }}/build
#
- name: Build Conda package using mamba build
run: conda mambabuild -c conda-forge -c openbiosim/label/dev ${{ github.workspace }}/biosimspace/recipes/biosimspace
#
- name: Upload Conda package
run: python ${{ github.workspace }}/biosimspace/actions/upload_package.py
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_LABEL: dev
52 changes: 14 additions & 38 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: Build
name: Release Main

on:
workflow_dispatch:
push:
branches: [ devel ]
pull_request:
branches: [ devel ]

# Note that push and pull-request builds are automatically
# now skipped by GitHub if
# [skip ci], [ci skip], [no ci], [skip actions], or [actions skip]
# are in the commit message. We don't need to check for this ourselves.

inputs:
upload_packages:
description: "Upload packages to anaconda (yes/no)?"
required: true
default: "no"
jobs:
build:
name: build (${{ matrix.python-version }}, ${{ matrix.platform.name }})
Expand All @@ -22,21 +17,9 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10"]
platform:
- {
name: "windows",
os: "windows-latest",
shell: "pwsh"
}
- {
name: "linux",
os: "ubuntu-latest",
shell: "bash -l {0}"
}
- {
name: "macos",
os: "macos-latest",
shell: "bash -l {0}"
}
- { name: "windows", os: "windows-latest", shell: "pwsh" }
- { name: "linux", os: "ubuntu-latest", shell: "bash -l {0}" }
- { name: "macos", os: "macos-latest", shell: "bash -l {0}" }
environment:
name: biosimspace-build
defaults:
Expand All @@ -45,7 +28,6 @@ jobs:
env:
SIRE_DONT_PHONEHOME: 1
SIRE_SILENT_PHONEHOME: 1
REPO: "${{ github.event.pull_request.head.repo.full_name || github.repository }}"
steps:
- uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -56,13 +38,8 @@ jobs:
miniforge-variant: Mambaforge
use-mamba: true
#
- name: Clone the devel branch (push to devel)
run: git clone https://github.com/${{ env.REPO }}
if: github.event_name != 'pull_request'
#
- name: Clone the feature branch (pull request to devel)
run: git clone -b ${{ github.head_ref }} --single-branch https://github.com/${{ env.REPO }}
if: github.event_name == 'pull_request'
- name: Clone the main branch
run: git clone -b main https://github.com/openbiosim/biosimspace
#
- name: Setup Conda
run: mamba install -y -c conda-forge boa anaconda-client packaging=21 pip-requirements-parser
Expand All @@ -74,12 +51,11 @@ jobs:
run: mkdir ${{ github.workspace }}/build
#
- name: Build Conda package using mamba build
run: conda mambabuild -c conda-forge -c openbiosim/label/dev ${{ github.workspace }}/biosimspace/recipes/biosimspace
run: conda mambabuild -c conda-forge -c openbiosim/label/main ${{ github.workspace }}/biosimspace/recipes/biosimspace
#
- name: Upload Conda package
run: python ${{ github.workspace }}/biosimspace/actions/upload_package.py
env:
SRC_DIR: ${{ github.workspace }}/biosimspace
BUILD_DIR: ${{ github.workspace }}/build
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
if: github.event_name != 'pull_request'
ANACONDA_LABEL: main
if: github.event.inputs.upload_packages == 'yes'
70 changes: 70 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Pull-Request

on:
pull_request:
branches: [devel, main]

jobs:
build:
name: build (${{ matrix.python-version }}, ${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
strategy:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
platform:
- { name: "windows", os: "windows-latest", shell: "pwsh" }
- { name: "linux", os: "ubuntu-latest", shell: "bash -l {0}" }
- { name: "macos", os: "macos-latest", shell: "bash -l {0}" }
exclude:
# Exclude all but the latest Python from all
# but Linux
- platform:
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
python-version: "3.8"
- platform: { name: "windows", os: "windows-latest", shell: "pwsh" }
python-version: "3.8"
- platform:
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
python-version: "3.9"
- platform: { name: "windows", os: "windows-latest", shell: "pwsh" }
python-version: "3.9"
environment:
name: biosimspace-build
defaults:
run:
shell: ${{ matrix.platform.shell }}
env:
SIRE_DONT_PHONEHOME: 1
SIRE_SILENT_PHONEHOME: 1
REPO: "${{ github.event.pull_request.head.repo.full_name || github.repository }}"
steps:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: bss_build
miniforge-version: latest
miniforge-variant: Mambaforge
use-mamba: true
#
- name: Clone the feature branch
run: git clone -b ${{ github.head_ref }} --single-branch https://github.com/${{ env.REPO }}
#
- name: Setup Conda
run: mamba install -y -c conda-forge boa anaconda-client packaging=21 pip-requirements-parser
#
- name: Update Conda recipe
run: python ${{ github.workspace }}/biosimspace/actions/update_recipe.py
#
- name: Prepare build location
run: mkdir ${{ github.workspace }}/build
#
- name: Build Conda package using mamba build using main channel
if: ${{ github.base_ref == 'main' }}
run: conda mambabuild -c conda-forge -c openbiosim/label/main ${{ github.workspace }}/biosimspace/recipes/biosimspace
#
- name: Build Conda package using mamba build using dev channel
if: ${{ github.base_ref != 'main' }}
run: conda mambabuild -c conda-forge -c openbiosim/label/dev ${{ github.workspace }}/biosimspace/recipes/biosimspace
17 changes: 7 additions & 10 deletions actions/upload_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
else:
conda_token = "TEST"

# Get the anaconda channel labels.
if "ANACONDA_LABEL" in os.environ:
conda_label = os.environ["ANACONDA_LABEL"]
else:
conda_label = "dev"

# get the root conda directory
conda = os.environ["CONDA"]

Expand Down Expand Up @@ -50,17 +56,8 @@ def run_cmd(cmd):

tag = run_cmd(f"git --git-dir={gitdir} --work-tree={srcdir} tag --contains")

# If the tag is not empty, then set the label to main (this is a release)
if tag is not None and tag.lstrip().rstrip() != "":
print(f"\nTag {tag} is set. This is a 'main' release.")
label = "--label main --label dev"
else:
# this is a development release
print("\nNo tag is set. This is a 'devel' release.")
label = "--label dev"

# Upload the packages to the openbiosim channel on Anaconda Cloud.
cmd = f"anaconda --token {conda_token} upload --user openbiosim {label} --force {packages}"
cmd = f"anaconda --token {conda_token} upload --user openbiosim --label {conda_label} --force {packages}"

print(f"\nUpload command:\n\n{cmd}\n")

Expand Down
3 changes: 3 additions & 0 deletions python/BioSimSpace/IO/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ def readMolecules(files, show_warnings=False, download_dir=None, property_map={}
raise TypeError("'files' must be a list of 'str' types.")
if len(files) == 0:
raise ValueError("The list of input files is empty!")
# Convert tuple to list.
if isinstance(files, tuple):
files = list(files)
else:
raise TypeError("'files' must be of type 'str', or a list of 'str' types.")

Expand Down
3 changes: 3 additions & 0 deletions python/BioSimSpace/Sandpit/Exscientia/IO/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ def readMolecules(files, show_warnings=False, download_dir=None, property_map={}
raise TypeError("'files' must be a list of 'str' types.")
if len(files) == 0:
raise ValueError("The list of input files is empty!")
# Convert tuple to list.
if isinstance(files, tuple):
files = list(files)
else:
raise TypeError("'files' must be of type 'str', or a list of 'str' types.")

Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)

# Check the Sire version.
if int(sire.legacy.__version__.replace(".", "")) < min_ver_int:
if int(sire.legacy.__version__.replace(".", "").replace("dev", "")) < min_ver_int:
raise ImportError("BioSimSpace requires Sire version '%s' or above." % min_ver)

from setuptools import setup, find_packages
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# BioSimSpace runtime requirements.

sire ~=2023.2.0
# main
sire~=2023.2.2

# devel
#sire==2023.3.0.dev

configargparse
ipywidgets<8
Expand Down
5 changes: 5 additions & 0 deletions test/IO/test_tuple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import BioSimSpace as BSS

def test_tuple():
"""Check that we can read from a tuple of files."""
BSS.IO.readMolecules(("test/input/ala.crd", "test/input/ala.top"))
5 changes: 5 additions & 0 deletions test/Sandpit/Exscientia/IO/test_tuple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import BioSimSpace.Sandpit.Exscientia as BSS

def test_tuple():
"""Check that we can read from a tuple of files."""
BSS.IO.readMolecules(("test/input/ala.crd", "test/input/ala.top"))

0 comments on commit 083dc3e

Please sign in to comment.