-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
176 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,109 @@ | ||
name: Conda Build | ||
name: Build | ||
|
||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- feature/cuda_integration # Adjust to your branch names as needed | ||
branches: [ devel ] | ||
pull_request: | ||
branches: | ||
- feature/cuda_integration # Adjust to your branch names as needed | ||
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: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: [3.9, 3.10, 3.11, 3.12] # Adjust Python versions as needed | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
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}" | ||
} | ||
environment: | ||
name: sire-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: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Miniconda | ||
uses: conda-incubator/setup-miniconda@v3 | ||
# Need to install and use VS 2017 for conda-compliant builds | ||
- name: Set up Visual Studio 2017 Build Tools (required for Python modules) | ||
run: | | ||
choco install visualstudio2017-workload-vctools | ||
if: matrix.platform.name == 'windows' | ||
# | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: base | ||
auto-update-conda: true | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install conda-build | ||
run: | | ||
conda install -c conda-forge boa | ||
run: | | ||
conda config --set anaconda_upload yes | ||
- name: Build conda package | ||
run: | | ||
conda mambabuild lyceanem/conda/ | ||
activate-environment: sire_build | ||
miniforge-version: latest | ||
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: 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 }}/Sire/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 michellab/label/dev ${{ github.workspace }}/Sire/recipes/sire | ||
# | ||
# - name: Collect failed artifacts | ||
# run: | ||
# python ${{ github.workspace }}/Sire/actions/collect_failed.py | ||
# env: | ||
# BUILD_DIR: ${{ github.workspace }}/build | ||
# if: ${{ failure() }} | ||
# | ||
# - uses: actions/upload-artifact@v3 | ||
# with: | ||
# name: build-${{ matrix.platform.name }}-${{matrix.python-version}}-${{ github.sha }} | ||
# path: ${{ github.workspace }}/build/*/sire-*.tar.bz2 | ||
# retention-days: 10 | ||
# if: ${{ success() }} | ||
# | ||
# - uses: actions/upload-artifact@v3 | ||
# with: | ||
# name: failed-${{ matrix.platform.name }}-${{matrix.python-version}}-${{ github.sha }} | ||
# path: ${{ github.workspace }}/build/failed.tar.bz2 | ||
# retention-days: 1 | ||
# if: ${{ failure() }} | ||
# | ||
- name: Upload Conda package | ||
run: python ${{ github.workspace }}/Sire/actions/upload_package.py | ||
env: | ||
SRC_DIR: ${{ github.workspace }}/Sire | ||
BUILD_DIR: ${{ github.workspace }}/build | ||
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | ||
if: github.event_name != 'pull_request' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
import os | ||
import sys | ||
import glob | ||
|
||
script = os.path.abspath(sys.argv[0]) | ||
|
||
# go up one directories to get the source directory | ||
# (this script is in Sire/actions/) | ||
srcdir = os.path.dirname(os.path.dirname(script)) | ||
|
||
print(f"sire source is in {srcdir}\n") | ||
|
||
# Get the anaconda token to authorise uploads | ||
if "ANACONDA_TOKEN" in os.environ: | ||
conda_token = os.environ["ANACONDA_TOKEN"] | ||
else: | ||
conda_token = "TEST" | ||
|
||
# get the root conda directory | ||
conda = os.environ["CONDA"] | ||
|
||
# Set the path to the conda-bld directory. | ||
conda_bld = os.path.join(conda, "envs", "sire_build", "conda-bld") | ||
|
||
print(f"conda_bld = {conda_bld}") | ||
|
||
# Find the packages to upload | ||
pkg_lycean = glob.glob(os.path.join(conda_bld, "*-*", "lyceanem-*.tar.bz2")) | ||
|
||
if len(pkg_lycean) == 0: | ||
print("No lyceanem packages to upload?") | ||
sys.exit(-1) | ||
|
||
packages = pkg_lycean | ||
|
||
|
||
|
||
print(f"Uploading packages:") | ||
|
||
|
||
|
||
|
||
|
||
def run_cmd(cmd): | ||
import subprocess | ||
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) | ||
return str(p.stdout.read().decode("utf-8")).lstrip().rstrip() | ||
|
||
gitdir = os.path.join(srcdir, ".git") | ||
|
||
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 michellab channel on Anaconda Cloud. | ||
cmd = f"anaconda --token {conda_token} upload --user tf17270 {label} --force {packages}" | ||
|
||
print(f"\nUpload command:\n\n{cmd}\n") | ||
|
||
# Label release packages with main and dev so that dev is at least as new as | ||
# main. Only need to uncomment the libcpuid and kcombu package uploads when | ||
# there new versions are released. | ||
if conda_token == "TEST": | ||
print("Not uploading as the ANACONDA_TOKEN is not set!") | ||
sys.exit(-1) | ||
|
||
output = run_cmd(cmd) | ||
|
||
print(output) | ||
|
||
print("Package uploaded!") |