Skip to content

Commit

Permalink
Merge pull request #403 from dougiesquire/issue-398
Browse files Browse the repository at this point in the history
Update to packaging tools and logic
  • Loading branch information
dougiesquire authored Jan 22, 2024
2 parents ca0c825 + e094ac4 commit 84f336a
Show file tree
Hide file tree
Showing 20 changed files with 869 additions and 408 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
payu/_version.py export-subst
75 changes: 39 additions & 36 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
name: CD

on: [push, pull_request]
on:
push:
tags:
- '*'

jobs:
conda:
name: build and deploy to conda
if: github.repository == 'payu-org/payu' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: 3.11
environment-file: conda/environment.yml
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Build and upload the conda package
uses: uibcdf/[email protected]
with:
meta_yaml_dir: conda
python-version: 3.11
user: accessnri
label: main
token: ${{ secrets.anaconda_token }}
env:
PY_VERSION: 3.11

jobs:
pypi-build:
name: Build package for PyPI
if: github.repository == 'payu-org/payu' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
if: github.repository == 'payu-org/payu'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: ${{ env.PY_VERSION }}

- run: |
python3 -m pip install --upgrade build && python3 -m build
Expand All @@ -54,7 +31,6 @@ jobs:
# Split build and publish to restrict trusted publishing to just this workflow
needs: ['pypi-build']
name: Publish to PyPI.org
if: github.repository == 'payu-org/payu' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
Expand All @@ -65,7 +41,34 @@ jobs:
path: artifact/

- name: Publish package distributions to PyPI
# This is version v1.8.10
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11
with:
packages-dir: artifact/

conda:
name: Build with conda and upload
if: github.repository == 'payu-org/payu'
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@11b562958363ec5770fef326fe8ef0366f8cbf8a # v3.0.1
with:
packages_dir: artifact/
miniconda-version: "latest"
python-version: ${{ env.PY_VERSION }}
environment-file: conda/environment.yml
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Build and upload the conda package
uses: uibcdf/action-build-and-upload-conda-packages@c6e7a90ad5e599d6cde76e130db4ee52ad733ecf # v1.2.0
with:
meta_yaml_dir: conda
python-version: ${{ env.PY_VERSION }}
user: accessnri
label: main
token: ${{ secrets.anaconda_token }}
40 changes: 28 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,50 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
PY_VERSION: 3.11

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
pypa-build:
name: PyPA build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PY_VERSION }}

- run: |
python3 -m pip install --upgrade build && python3 -m build
- uses: actions/upload-artifact@v3
with:
path: ./dist

conda-build:
name: Conda Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@11b562958363ec5770fef326fe8ef0366f8cbf8a # v3.0.1
with:
miniconda-version: "latest"
python-version: 3.11
python-version: ${{ env.PY_VERSION }}
environment-file: conda/environment.yml
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Run conda build
shell: bash -el {0}
# For the build, these environment variables would usually be set based on repo tags,
# but they can be these defaults instead since we don't use the build
env:
GIT_DESCRIBE_TAG: test
GIT_DESCRIBE_NUMBER: 0
run: conda build . --no-anaconda-upload

build:
tests:
name: Tests
runs-on: ubuntu-latest

# Run the job for different versions of python
Expand Down Expand Up @@ -76,18 +92,18 @@ jobs:
PYTHONPATH=. pytest --cov=payu -s test;
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
uses: AndreMiras/coveralls-python-action@f5fd5c309b39d01599fb92c72d4f7409ea78aec9 # v20201129
with:
parallel: true

- name: Make docs
run: cd docs && make html

coveralls_finish:
needs: build
name: Coveralls Finished
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
- uses: AndreMiras/coveralls-python-action@f5fd5c309b39d01599fb92c72d4f7409ea78aec9 # v20201129
with:
parallel-finished: true
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MAIN]

# Files or directories to be skipped. They should be base names, not
# paths.
ignore=_version.py
4 changes: 0 additions & 4 deletions bin/payu

This file was deleted.

4 changes: 0 additions & 4 deletions bin/payu-collate

This file was deleted.

4 changes: 0 additions & 4 deletions bin/payu-profile

This file was deleted.

4 changes: 0 additions & 4 deletions bin/payu-run

This file was deleted.

4 changes: 0 additions & 4 deletions bin/payu-sync

This file was deleted.

1 change: 1 addition & 0 deletions conda/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependencies:
- anaconda-client
- conda-build
- conda-verify
- versioneer
56 changes: 25 additions & 31 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}
{% set version = data.get('version') %}
{% set pyproj = load_file_data('../pyproject.toml', from_recipe_dir=True) %}
{% set project = pyproj.get('project') %}

package:
name: payu
version: {{ GIT_DESCRIBE_TAG }}
version: "{{ version }}"

build:
noarch: python
number: {{ GIT_DESCRIBE_NUMBER }}
script: "{{ PYTHON }} -m pip install . --no-deps"
number: 0
script: "{{ PYTHON }} -m pip install . -vv"
entry_points:
- payu = payu.cli:parse
- payu-run = payu.subcommands.run_cmd:runscript
- payu-collate = payu.subcommands.collate_cmd:runscript
- payu-profile = payu.subcommands.profile_cmd:runscript
- payu-sync = payu.subcommands.sync_cmd:runscript
- payu-branch = payu.subcommands.branch_cmd:runscript
- payu-clone = payu.subcommands.clone_cmd:runscript
- payu-checkout = payu.subcommands.checkout_cmd:runscript
{% for name, script in project.get('scripts', {}).items() %}
- {{ name }} = {{ script }}
{% endfor %}

source:
git_url: ../
path: ../

requirements:
build:
- python <=3.11
- pbr
- setuptools
host:
- python
- pip
- setuptools >=61.0.0
- versioneer
run:
- python <=3.11
- f90nml >=0.16
- yamanifest >=0.3.4
- PyYAML
- python-dateutil
- tenacity
- requests
- cftime
# The following two requirements are from the security
# extra for the pypi package
- pyOpenSSL >=0.14
- cryptography>=1.3.4
- GitPython >=3.1.40
- ruamel.yaml >=0.18.5
- python >=3.9
{% for dep in project.get('dependencies', []) %}
- {{ dep }}
{% endfor %}

test:
imports:
- payu
commands:
- payu list


about:
home: https://github.com/payu-org/payu/
license: Apache Software
license_family: APACHE
summary: "A climate model workflow manager for supercomputing environments"
doc_url: https://payu.readthedocs.io/en/latest/
3 changes: 2 additions & 1 deletion payu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
:copyright: Copyright 2011 Marshall Ward, see AUTHORS for details.
:license: Apache License, Version 2.0, see LICENSE for details.
"""
__version__ = '1.0.19'
from . import _version
__version__ = _version.get_versions()['version']
Loading

0 comments on commit 84f336a

Please sign in to comment.