Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github CI/CD workflows #19

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
79 changes: 0 additions & 79 deletions .circleci/config.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .conda/env_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
channels:
- accessnri
- conda-forge
- coecms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, when do we get rid of the coecms dependency, given it's shut down now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a dependency on nchash (https://github.com/aidanheerdegen/nchash) which is deployed to the coecms conda channel. Though I'm unsure on whether the dependency is still required - see this existing issue: #11.

- nodefaults

dependencies:
- anaconda-client
- conda-build
- conda-verify
- versioneer
6 changes: 6 additions & 0 deletions conda/dev-environment.yml → .conda/env_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ dependencies:
- pbr
- netcdf4
- libnetcdf
- six
- PyYAML
- nchash>=0.1.5
- pytest
- pytest-cov
- versioneer
45 changes: 45 additions & 0 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% set version = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True).get('version') %}
{% set project = load_file_data('../pyproject.toml', from_recipe_dir=True).get('project') %}

package:
name: {{ project.get('name') }}
version: "{{ version }}"

build:
noarch: python
number: 0
script: "python3 -m pip install . -vv"
entry_points:
{% for name, script in project.get('scripts').items() %}
- {{ name }} = {{ script }}
{% endfor %}

source:
path: ../

requirements:
build:
- python
- pip
- setuptools >=61.0.0
- versioneer
run:
- python
- six
- pyyaml
- nchash

test:
imports:
- yamanifest
commands:
{% for name, script in project.get('scripts').items() %}
- {{ name }} --help
{% endfor %}

about:
home: {{ project.get('urls').get('Repository') }}
license: Apache Software
license_file: LICENSE
summary: {{ project.get('description') }}
license_family: Apache
37 changes: 37 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CD

on:
push:
tags:
- '*'

jobs:

conda:
name: Build with conda and upload
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@11b562958363ec5770fef326fe8ef0366f8cbf8a
with:
miniconda-version: "latest"
python-version: ${{ vars.PY_VERSION }}
environment-file: .conda/env_build.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
with:
meta_yaml_dir: .conda
python-version: ${{ vars.PY_VERSION }}
user: accessnri
label: main
token: ${{ secrets.ANACONDA_TOKEN }}
123 changes: 123 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Run CI tests
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: main
pull_request:
branches: main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
# JOB to run change in the build files
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
files: ${{ steps.filter.outputs.files }}
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7

- name: Filter files
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2
id: filter
with:
filters: |
files:
- 'pyproject.toml'
- 'setup.py'
- '.conda/env_build.yml'
- '.conda/meta.yml'

verify-conda-build:
name: Conda Build
runs-on: ubuntu-latest
needs: changes
# Only run if there are changes in the build files
if: ${{ needs.changes.outputs.files == 'true' }}
steps:
- uses: actions/checkout@v4

- name: Setup conda build environment
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
with:
miniconda-version: "latest"
python-version: ${{ vars.PY_VERSION }}
environment-file: .conda/env_build.yml
auto-activate-base: false
auto-update-conda: false
show-channel-urls: true

- name: Verify conda recipe
shell: bash -el {0}
# Ignores:
# C2105 - Found invalid package version in meta.yaml
# C2122 - Found invalid license family
run: conda-verify .conda --ignore C2105,C2122 --exit

- name: Run conda build
shell: bash -el {0}
run: |
conda build . --no-anaconda-upload --output-folder=./build

- name: Verify conda package
shell: bash -el {0}
# Ignores:
# C1105 - Found invalid version number in info/index.json
# C1115 - Found invalid license in info/index.json
# C1141 - Found python file without a corresponding pyc file
run: conda-verify ./build/noarch/*.tar.bz2 --ignore C1105,C1115,C1141 --exit

tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
environment-file: .conda/env_dev.yml
activate-environment: yamanifest-dev
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Install source
shell: bash -l {0}
run: python3 -m pip install --no-deps --no-build-isolation -e .

- name: List installed packages
shell: bash -l {0}
run: conda list

- name: Entrypoint test of driver script
shell: bash -l {0}
run: yamf --help

- name: Run tests
shell: bash -l {0}
run: |
python -m pytest --cov=yamanifest --cov-report=html -s test

# - name: Upload code coverage
# # Only upload once for the installed version
# if: ${{ matrix.python-version == vars.PY_VERSION }}
# uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 #v4.6.0
# with:
# token: ${{ secrets.codecov_token }}
# files: ./coverage.xml
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ target/
*.res
*.bin
*_table
*.yaml
# Commenting out so meta.yaml is tracked by git
# *.yaml
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

File renamed without changes.
13 changes: 4 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Install

Conda install::

conda install -c coecms yamanifest
conda install -c access-nri yamanifest

Pip install (into a virtual environment)::

Expand All @@ -44,19 +44,14 @@ Develop

Development install::

git checkout https://github.com/aidanheerdegen/yamanifest
git checkout https://github.com/ACCESS-NRI/yamanifest
cd yamanifest
conda env create -f conda/dev-environment.yml
conda env create -f .conda/env_dev.yml
source activate yamanifest-dev
pip install -e '.[dev]'

The `dev-environment.yml` file is for speeding up installs and installing
packages unavailable on pypi, `requirements.txt` is the source of truth for
dependencies.

Run tests::

py.test
python -m pytest -s

Build documentation::

Expand Down
Loading