Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

feat: Setup packaging and Github Codespaces dev environment #26

Merged
merged 45 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
031a576
Update README.md
uwcdc Nov 2, 2023
e6c64ce
Move project to src/ directory
uwcdc Nov 2, 2023
9907f5b
Update Codespaces link
uwcdc Nov 2, 2023
f4607ee
Update README.md
uwcdc Nov 2, 2023
ce49ca8
Update README.md
uwcdc Nov 2, 2023
ad11871
Update devcontainer
uwcdc Nov 7, 2023
00c6832
ci: Create cd.yml for building and pushing package
lsetiawan Nov 6, 2023
cdef4c9
Update caustic name to caustics
uwcdc Nov 7, 2023
d217513
Add PyLint and Black formatting features to devcon
uwcdc Nov 7, 2023
a2b2e17
Closes issue uw-ssec/caustics#16
uwcdc Nov 7, 2023
ce79301
Updated test/ -> tests/
uwcdc Nov 7, 2023
c2c175e
Move project to src/ directory
uwcdc Nov 2, 2023
7c9a73e
Update README.md
uwcdc Nov 2, 2023
aa2afdc
Update README.md
uwcdc Nov 2, 2023
9741818
Create noxfile.py
uwcdc Nov 20, 2023
8b1c26c
Add .readthedocs.yaml
uwcdc Nov 20, 2023
155729c
Create .git_archival.txt
uwcdc Nov 20, 2023
02f6ce7
Create .gitattributes
uwcdc Nov 20, 2023
c68da79
Create .pre-commit-config.yaml
uwcdc Nov 20, 2023
3dd0f3e
Add sphinx and myst-parser support
uwcdc Nov 20, 2023
c132388
style: pre-commit fixes
pre-commit-ci[bot] Nov 20, 2023
92b2ab8
Update docs
uwcdc Nov 20, 2023
7b216a1
style: pre-commit fixes
pre-commit-ci[bot] Nov 20, 2023
cdcad0f
Update .github Actions
uwcdc Nov 20, 2023
b12b171
Update environment.yml
uwcdc Nov 20, 2023
fc3f00c
Create CONTRIBUTING.md
uwcdc Nov 20, 2023
0d7949c
Update README.md
uwcdc Nov 20, 2023
8fe5ced
chore: resolve conflicts
lsetiawan Nov 27, 2023
a1f168f
chore: Remove sources
lsetiawan Nov 27, 2023
ae9c3f3
test: remove test lenses
lsetiawan Nov 27, 2023
7cd6a22
test: fix test_simulator
lsetiawan Nov 27, 2023
eb0ee85
chore: Set min python to 3.9
lsetiawan Nov 27, 2023
d719523
fix: change pytest to point to tests/
lsetiawan Nov 27, 2023
c02b339
build: update dep list to use reqs.txt
lsetiawan Nov 27, 2023
10b58ce
ci: Don't fail fast
lsetiawan Nov 27, 2023
024faf2
chore(deps): Pin astropy < 6
lsetiawan Nov 27, 2023
05fb594
fix: change instances of caustic to caustics
lsetiawan Nov 27, 2023
dedf57c
fix: Perform pre-commit
lsetiawan Nov 27, 2023
188aa67
fix: update path to conf.py
lsetiawan Nov 27, 2023
a63802a
update README
lsetiawan Nov 27, 2023
c1dcfba
style: pre-commit fixes
pre-commit-ci[bot] Nov 27, 2023
87e4527
docs: Add contributor graph
lsetiawan Nov 27, 2023
5923b53
chore: Setup dynamic versioning
lsetiawan Nov 27, 2023
1e676a5
ci: Update fetch depth to 0 to get correct version
lsetiawan Nov 27, 2023
4e03179
Update README.md
uwcdc Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
git
ncdu
wget
curl
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"image": "quay.io/pangeo/pytorch-notebook:latest",

"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"DavidAnson.vscode-markdownlint",
"GitHub.copilot"
]
}
},
"postCreateCommand": "sh .devcontainer/postBuild.sh",
"features": {
"ghcr.io/devcontainers-contrib/features/black:2": {},
"ghcr.io/devcontainers-contrib/features/pylint:2": {}
}
}
15 changes: 15 additions & 0 deletions .devcontainer/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
channels:
- conda-forge
dependencies:
- python>=3.10
- astropy
- jupyterlab
- matplotlib
- numpy
- pandas
- scipy
- h5py
- sphinx
- myst-parser
- jupyter-book
- pip
4 changes: 4 additions & 0 deletions .devcontainer/postBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For writing commands that will be executed after the container is created

# Installs `caustic` as local library without resolving dependencies (--no-deps)
python3 -m pip install -e /workspaces/caustics --no-deps
12 changes: 12 additions & 0 deletions .devcontainer/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -l

# ==== ONLY EDIT WITHIN THIS BLOCK =====

export CAUSTICS_ENV="caustics"
if ! [[ -z "${CAUSTICS_SCRATCH_PREFIX}" ]] && ! [[ -z "${JUPYTERHUB_USER}" ]]; then
export CAUSTICS_SCRATCH="${CAUSTICS_SCRATCH_PREFIX}/${JUPYTERHUB_USER}/"
fi

# ==== ONLY EDIT WITHIN THIS BLOCK =====

exec "$@"
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
101 changes: 101 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
description of best practices for developing scientific packages.

[spc-dev-intro]: https://scientific-python-cookie.readthedocs.io/guide/intro

# Quick development

The fastest way to start with development is to use nox. If you don't have nox,
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
If you don't have pipx (pip for applications), then you can install with with
`pip install pipx` (the only case were installing an application with regular
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
`brew install pipx nox`.

To use, run `nox`. This will lint and test using every installed version of
Python on your system, skipping ones that are not installed. You can also run
specific jobs:

```console
$ nox -s lint # Lint only
$ nox -s tests # Python tests
$ nox -s docs -- serve # Build and serve the docs
$ nox -s build # Make an SDist and wheel
```

Nox handles everything for you, including setting up an temporary virtual
environment for each run.

# Setting up a development environment manually

You can set up a development environment by running:

```bash
python3 -m venv .venv
source ./.venv/bin/activate
pip install -v -e .[dev]
```

If you have the
[Python Launcher for Unix](https://github.com/brettcannon/python-launcher), you
can instead do:

```bash
py -m venv .venv
py -m install -v -e .[dev]
```

# Post setup

You should prepare pre-commit, which will help you by checking that commits pass
required checks:

```bash
pip install pre-commit # or brew install pre-commit on macOS
pre-commit install # Will install a pre-commit hook into the git repo
```

You can also/alternatively run `pre-commit run` (changes only) or
`pre-commit run --all-files` to check even without installing the hook.

# Testing

Use pytest to run the unit checks:

```bash
pytest
```

# Coverage

Use pytest-cov to generate coverage reports:

```bash
pytest --cov=caustics
```

# Building docs

You can build the docs using:

```bash
nox -s docs
```

You can see a preview with:

```bash
nox -s docs -- serve
```

# Pre-commit

This project uses pre-commit for all style checking. While you can run it with
nox, this is such an important tool that it deserves to be installed on its own.
Install pre-commit and run:

```bash
pre-commit run -a
```

to check all files.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
32 changes: 32 additions & 0 deletions .github/matchers/pylint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"problemMatcher": [
{
"severity": "warning",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-warning"
},
{
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
],
"owner": "pylint-error"
}
]
}
99 changes: 99 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CD

on:
workflow_dispatch:
push:
branches:
- main
- dev
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest

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

- name: Build sdist and wheel
run: pipx run build

- uses: actions/upload-artifact@v3
with:
path: dist

- name: Check products
run: pipx run twine check dist/*

test-built-dist:
needs: [dist]
name: Test built distribution
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/[email protected]
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- name: Check pypi packages
run: |
sleep 3
python -m pip install --upgrade pip

echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre caustic
python -c "import caustic; print(caustics.__version__)"
echo "=== Done testing wheel file ==="

echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes caustic
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: caustic
python -c "import caustic; print(caustics.__version__)"
echo "=== Done testing source tar file ==="

publish:
needs: [dist, test-built-dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/[email protected]
if: startsWith(github.ref, 'refs/tags')
Loading