Skip to content

Commit

Permalink
Merge branch 'improve-setup-ci'
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenain committed Feb 7, 2023
2 parents 7391076 + c494f88 commit 52da30c
Show file tree
Hide file tree
Showing 45 changed files with 212 additions and 76 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches:
- master
tags:
- '**'
pull_request:

env:
NUMBA_NUM_THREADS: 1
MPLBACKEND: Agg
PYTEST_ADDOPTS: --color=yes

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
ctapipe-version: [v0.12.0]

defaults:
run:
shell: bash -leo pipefail {0}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Python version
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
sed -i -e "s/- python=.*/- python=$PYTHON_VERSION/g" environment.yml
- name: Create and activate env
uses: mamba-org/provision-with-micromamba@v15
with:
environment-name: "ci"
environment-file: environment.yml

- name: Install dependencies
env:
PYTHON_VERSION: ${{ matrix.python-version }}
CTAPIPE_VERSION: ${{ matrix.ctapipe-version }}

run: |
python --version
echo "Installing additional pip packages"
# we install ctapipe using pip to be able to select any commit, e.g. the current master
pip install \
"git+https://github.com/cta-observatory/ctapipe@$CTAPIPE_VERSION" \
pytest-cov
echo "pip install -e ."
pip install -e .
- name: Tests
run: |
pytest --cov=nectarchain --cov-report=xml
- uses: codecov/codecov-action@v1
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy to PyPI

on:
push:
tags:
- 'v*'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# make sure we have version info
- run: git fetch --tags

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
python --version
pip install -U pip setuptools wheel setuptools_scm[toml]
python setup.py sdist bdist_wheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_version.py
.pytest_cache

# Compiled files
Expand All @@ -8,7 +9,7 @@
__pycache__

# ignore version cache file (generated automatically when setup.py is run)
nectarcam/_version_cache.py
src/nectarchain/_version_cache.py

# Ignore .c files by default to avoid including generated code. If you want to
# add a non-generated .c extension, use `git add -f filename.c`.
Expand Down
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# nectarchain
# nectarchain [![Build Status](https://github.com/cta-observatory/nectarchain/workflows/CI/badge.svg?branch=master)](https://github.com/cta-observatory/nectarchain/actions?query=workflow%3ACI+branch%3Amaster)

Repository for the high level analysis of the NectarCAM data.
The analysis is heavily based on [ctapipe](https://github.com/cta-observatory/ctapipe), adding custom code for NectarCAM calibration.

master branch status: [![Build Status](https://travis-ci.org/cta-observatory/nectarchain.svg?branch=master)](https://travis-ci.org/cta-observatory/nectarchain)

## Installation

```shell
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools >= 64.0.3", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/nectarchain/_version.py"
57 changes: 57 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[metadata]
name = nectarchain
description = Analysis chain for the CTA MSTN NectarCAM prototype
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
author = NectarCAM collaboration
license = BSD-3-Clause

project_urls =
Bug Tracker = https://github.com/cta-observatory/nectarchain/issues
Source Code = https://github.com/cta-observatory/nectarchain

classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: BSD License
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Astronomy
Topic :: Scientific/Engineering :: Physics
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8

[options]
packages = find:
package_dir =
= src
python_requires = ~=3.8
zip_safe = False
install_requires =
astropy~=4.2
ctapipe~=0.12
numpy~=1.22
protozfits~=2.0
tables>=3.7

[options.packages.find]
where = src
exclude =
nectarchain._dev_version

[options.extras_require]
tests =
pytest
dev =
setuptools_scm[toml]
all =
%(tests)s
%(dev)s

[tool:pytest]
minversion = 3.0
addopts = -v

[aliases]
test = pytest

[flake8]
max-line-length = 88
34 changes: 2 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from setuptools import setup, find_packages
from os import path

# read the contents of your README file
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()


setup(
name='nectarchain',
packages=find_packages(),
version='0.1',
description='',
long_description=long_description,
long_description_content_type='text/markdown',
install_requires=[
'astropy~=4.2',
'ctapipe~=0.12',
'numpy~=1.22.4',
'tables>=3.7',
],
tests_require=['pytest'],
setup_requires=['pytest_runner'],
author='NectarCAM collaboration',
url='https://github.com/cta-observatory/nectarchain',
license=''
)

from setuptools import setup
setup()
9 changes: 9 additions & 0 deletions src/nectarchain/_dev_version/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Try to use setuptools_scm to get the current version; this is only used
# in development installations from the git repository.
# see nectarchain/version.py for details
try:
from setuptools_scm import get_version

version = get_version(root="..", relative_to=__file__)
except Exception as e:
raise ImportError(f"setuptools_scm broken or not installed: {e}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions src/nectarchain/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# this is adapted from https://github.com/astropy/astropy/blob/master/astropy/version.py
# see https://github.com/astropy/astropy/pull/10774 for a discussion on why this needed.

try:
try:
from ._dev_version import version
except ImportError:
from ._version import version
except Exception:
import warnings

warnings.warn(
"Could not determine nectarchain version; this indicates a broken installation."
" Install nectarchain from PyPI, using conda or from a local git repository."
" Installing github's autogenerated source release tarballs "
" does not include version information and should be avoided."
)
del warnings
version = "0.0.0"

__version__ = version

0 comments on commit 52da30c

Please sign in to comment.