Skip to content

Commit

Permalink
Merge pull request #28 from cmu-delphi/ds/fixup
Browse files Browse the repository at this point in the history
refactor+clean: simplify package internals and clean configs
  • Loading branch information
dshemetov authored Jul 15, 2024
2 parents a929bf9 + 871c832 commit 9584e18
Show file tree
Hide file tree
Showing 37 changed files with 814 additions and 1,291 deletions.
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 4
Expand All @@ -19,3 +18,6 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Run repo through formatter
c7831fc0fa1367d8517831996539ce0c6c48aa58
# Run repo through formatter
57908fc0099685a6cad6bfe6996182e6295411df
39 changes: 0 additions & 39 deletions .github/workflows/ci.yaml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci

on: push

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install Dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
- name: Check Formatting
run: |
source venv/bin/activate
inv lint-black
- name: Check Linting
run: |
source venv/bin/activate
inv lint-pylint
- name: Check Types
run: |
source venv/bin/activate
inv lint-mypy
- name: Test
run: |
source venv/bin/activate
inv test
27 changes: 21 additions & 6 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ on:
description: "Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)"
required: true
default: patch

jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: main
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
Expand All @@ -20,24 +21,38 @@ jobs:
git fetch origin dev:dev
git reset --hard dev
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Change version number
id: version
# See this issue for explanation and testing:
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
run: |
python -m pip install bump2version
echo -n "::set-output name=next_tag::"
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# use given version number
NEXT_TAG="${{ github.event.inputs.versionName }}"
elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
# calculate new version number based on given tag
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
else
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
exit 1
fi
# apply given or calculated version number
bump2version --new-version $NEXT_TAG _ignored_arg_
# save version number for later
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
- name: Create pull request into main
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v6
with:
branch: release/${{ steps.version.outputs.next_tag }}
commit-message: "chore: release ${{ steps.version.outputs.next_tag }}"
base: main
title: Release ${{ steps.version.outputs.next_tag }}
labels: chore
# reviewers:
assignees: melange396
assignees: dshemetov
body: |
Releasing ${{ steps.version.outputs.next_tag }}.
65 changes: 45 additions & 20 deletions .github/workflows/release_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Extract version
id: extract_version
run: |
python -m pip install bump2version
echo -n "::set-output name=version::"
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
NEXT_TAG=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
echo "version=$NEXT_TAG" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v5
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -41,20 +41,19 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag_name: ${{ steps.create_release.outputs.tag_name }}

release_package:
needs: create_release
lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install --use-feature=2020-resolver -r requirements.txt -r requirements-dev.txt
pip install -e ".[dev]"
- name: Linting
run: |
. venv/bin/activate
Expand All @@ -63,32 +62,58 @@ jobs:
run: |
. venv/bin/activate
inv test
- name: Create release
build:
needs: [create_release, lint]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Build
run: |
inv dist
- uses: actions/upload-artifact@v2
release_package:
needs: [create_release, lint]
runs-on: ubuntu-latest
# TODO: Make sure this works, copied from best practices here
# https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing
environment:
name: pypi
url: https://pypi.org/p/epidatpy
permissions:
id-token: write
steps:
- uses: actions/upload-artifact@v4
with:
name: epidatpy
path: dist/*.tar.gz
- name: Upload Release Asset
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: "dist/*.tar.gz"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ needs.create_release.outputs.tag_name }}
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
skip_existing: true
skip-existing: true
# repository_url: https://test.pypi.org/legacy/

sync_dev:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: dev
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
Expand All @@ -97,14 +122,14 @@ jobs:
git fetch origin main:main
git reset --hard main
- name: Create pull request into dev
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v6
with:
branch: bot/sync-main-dev
commit-message: "chore: sync main-dev"
base: dev
title: "chore: sync main->dev"
labels: chore
# reviewers:
assignees: melange396
# reviewers:
assignees: dshemetov
body: |
Syncing Main->Dev.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.mypy_cache
*.pyc
__pycache__
/venv
/docs/_build
.coverage
.pytest_cache
.DS_Store
*.egg-info
/dist
.DS_Store
dist/
build/
docs/_build
venv/
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.1
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# Delphi Epidata Python Client `epidatpy`
# `epidatpy`

[![License: MIT][mit-image]][mit-url] [![Github Actions][github-actions-image]][github-actions-url] [![PyPi][pypi-image]][pypi-url] [![Read the Docs][docs-image]][docs-url]

A Python client for the [Delphi Epidata API](https://cmu-delphi.github.io/delphi-epidata/).

## Install

Install latest version:
Install with the following commands:

```sh
# Latest dev version
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"

# PyPI version (not yet available)
pip install epidatpy
```

## Usage

TODO

## Development Environment
## Development

Prepare virtual environment and install dependencies

```sh
python -m venv venv
source ./venv/bin/activate
pip install --use-feature=2020-resolver -r requirements.txt -r requirements-dev.txt
pip install -e ".[dev]"
```

### Common Commands
Expand All @@ -38,7 +44,7 @@ inv dist # build distribution packages
inv release # upload the current version to pypi
```

## Release Process
### Release Process

The release consists of multiple steps which can be all done via the GitHub website:

Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading

0 comments on commit 9584e18

Please sign in to comment.