Skip to content

Commit 9584e18

Browse files
authored
Merge pull request #28 from cmu-delphi/ds/fixup
refactor+clean: simplify package internals and clean configs
2 parents a929bf9 + 871c832 commit 9584e18

37 files changed

+814
-1291
lines changed

.dockerignore

-2
This file was deleted.

.editorconfig

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ root = true
66

77

88
[*]
9-
109
# Change these settings to your own preference
1110
indent_style = space
1211
indent_size = 4
@@ -19,3 +18,6 @@ insert_final_newline = true
1918

2019
[*.md]
2120
trim_trailing_whitespace = false
21+
22+
[*.yml]
23+
indent_size = 2

.git-blame-ignore-revs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Run repo through formatter
2+
c7831fc0fa1367d8517831996539ce0c6c48aa58
3+
# Run repo through formatter
4+
57908fc0099685a6cad6bfe6996182e6295411df

.github/workflows/ci.yaml

-39
This file was deleted.

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ci
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: [3.8]
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
cache: "pip"
19+
- name: Install Dependencies
20+
run: |
21+
python -m venv venv
22+
source venv/bin/activate
23+
pip install -e ".[dev]"
24+
- name: Check Formatting
25+
run: |
26+
source venv/bin/activate
27+
inv lint-black
28+
- name: Check Linting
29+
run: |
30+
source venv/bin/activate
31+
inv lint-pylint
32+
- name: Check Types
33+
run: |
34+
source venv/bin/activate
35+
inv lint-mypy
36+
- name: Test
37+
run: |
38+
source venv/bin/activate
39+
inv test

.github/workflows/create_release.yml

+21-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ on:
66
description: "Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)"
77
required: true
88
default: patch
9+
910
jobs:
1011
create_release:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Check out code
14-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1516
with:
1617
ref: main
1718
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
@@ -20,24 +21,38 @@ jobs:
2021
git fetch origin dev:dev
2122
git reset --hard dev
2223
- name: Set up Python 3.8
23-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v5
2425
with:
2526
python-version: 3.8
2627
- name: Change version number
2728
id: version
29+
# See this issue for explanation and testing:
30+
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
2831
run: |
2932
python -m pip install bump2version
30-
echo -n "::set-output name=next_tag::"
31-
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
33+
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
34+
# use given version number
35+
NEXT_TAG="${{ github.event.inputs.versionName }}"
36+
elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
37+
# calculate new version number based on given tag
38+
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
39+
else
40+
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
41+
exit 1
42+
fi
43+
# apply given or calculated version number
44+
bump2version --new-version $NEXT_TAG _ignored_arg_
45+
# save version number for later
46+
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
3247
- name: Create pull request into main
33-
uses: peter-evans/create-pull-request@v3
48+
uses: peter-evans/create-pull-request@v6
3449
with:
3550
branch: release/${{ steps.version.outputs.next_tag }}
3651
commit-message: "chore: release ${{ steps.version.outputs.next_tag }}"
3752
base: main
3853
title: Release ${{ steps.version.outputs.next_tag }}
3954
labels: chore
4055
# reviewers:
41-
assignees: melange396
56+
assignees: dshemetov
4257
body: |
4358
Releasing ${{ steps.version.outputs.next_tag }}.

.github/workflows/release_helper.yml

+45-20
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Check out code
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2121
- name: Set up Python 3.8
22-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: 3.8
2525
- name: Extract version
2626
id: extract_version
2727
run: |
2828
python -m pip install bump2version
29-
echo -n "::set-output name=version::"
30-
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
29+
NEXT_TAG=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
30+
echo "version=$NEXT_TAG" >> $GITHUB_OUTPUT
3131
- name: Create Release
3232
id: create_release
33-
uses: release-drafter/release-drafter@v5
33+
uses: release-drafter/release-drafter@v6
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3636
with:
@@ -41,20 +41,19 @@ jobs:
4141
upload_url: ${{ steps.create_release.outputs.upload_url }}
4242
tag_name: ${{ steps.create_release.outputs.tag_name }}
4343

44-
release_package:
45-
needs: create_release
44+
lint:
4645
runs-on: ubuntu-latest
4746
steps:
4847
- name: Check out code
49-
uses: actions/checkout@v2
48+
uses: actions/checkout@v4
5049
- name: Set up Python 3.8
51-
uses: actions/setup-python@v2
50+
uses: actions/setup-python@v5
5251
with:
5352
python-version: 3.8
5453
- name: Install build dependencies
5554
run: |
5655
python -m pip install --upgrade pip
57-
pip install --use-feature=2020-resolver -r requirements.txt -r requirements-dev.txt
56+
pip install -e ".[dev]"
5857
- name: Linting
5958
run: |
6059
. venv/bin/activate
@@ -63,32 +62,58 @@ jobs:
6362
run: |
6463
. venv/bin/activate
6564
inv test
66-
- name: Create release
65+
66+
build:
67+
needs: [create_release, lint]
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Check out code
71+
uses: actions/checkout@v4
72+
- name: Set up Python 3.8
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: 3.8
76+
- name: Install build dependencies
77+
run: |
78+
python -m pip install --upgrade pip
79+
pip install -e ".[dev]"
80+
- name: Build
6781
run: |
6882
inv dist
69-
- uses: actions/upload-artifact@v2
83+
84+
release_package:
85+
needs: [create_release, lint]
86+
runs-on: ubuntu-latest
87+
# TODO: Make sure this works, copied from best practices here
88+
# https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing
89+
environment:
90+
name: pypi
91+
url: https://pypi.org/p/epidatpy
92+
permissions:
93+
id-token: write
94+
steps:
95+
- uses: actions/upload-artifact@v4
7096
with:
7197
name: epidatpy
98+
path: dist/*.tar.gz
7299
- name: Upload Release Asset
73-
uses: AButler/upload-release-assets@v2.0
100+
uses: AButler/upload-release-assets@v3.0
74101
with:
75102
files: "dist/*.tar.gz"
76103
repo-token: ${{ secrets.GITHUB_TOKEN }}
77104
release-tag: ${{ needs.create_release.outputs.tag_name }}
78105
- name: Publish a Python distribution to PyPI
79106
uses: pypa/gh-action-pypi-publish@release/v1
80107
with:
81-
user: __token__
82-
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
83-
skip_existing: true
108+
skip-existing: true
84109
# repository_url: https://test.pypi.org/legacy/
85110

86111
sync_dev:
87112
needs: correct_repository
88113
runs-on: ubuntu-latest
89114
steps:
90115
- name: Check out code
91-
uses: actions/checkout@v2
116+
uses: actions/checkout@v4
92117
with:
93118
ref: dev
94119
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
@@ -97,14 +122,14 @@ jobs:
97122
git fetch origin main:main
98123
git reset --hard main
99124
- name: Create pull request into dev
100-
uses: peter-evans/create-pull-request@v3
125+
uses: peter-evans/create-pull-request@v6
101126
with:
102127
branch: bot/sync-main-dev
103128
commit-message: "chore: sync main-dev"
104129
base: dev
105130
title: "chore: sync main->dev"
106131
labels: chore
107-
# reviewers:
108-
assignees: melange396
132+
# reviewers:
133+
assignees: dshemetov
109134
body: |
110135
Syncing Main->Dev.

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.mypy_cache
22
*.pyc
33
__pycache__
4-
/venv
5-
/docs/_build
64
.coverage
75
.pytest_cache
6+
.DS_Store
87
*.egg-info
9-
/dist
10-
.DS_Store
8+
dist/
9+
build/
10+
docs/_build
11+
venv/

.pre-commit-config.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.5.1
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [--fix]
9+
# Run the formatter.
10+
- id: ruff-format

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
# Delphi Epidata Python Client `epidatpy`
1+
# `epidatpy`
22

33
[![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]
44

5+
A Python client for the [Delphi Epidata API](https://cmu-delphi.github.io/delphi-epidata/).
6+
57
## Install
68

7-
Install latest version:
9+
Install with the following commands:
810

911
```sh
12+
# Latest dev version
1013
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
14+
15+
# PyPI version (not yet available)
16+
pip install epidatpy
1117
```
1218

1319
## Usage
1420

1521
TODO
1622

17-
## Development Environment
23+
## Development
1824

1925
Prepare virtual environment and install dependencies
2026

2127
```sh
2228
python -m venv venv
2329
source ./venv/bin/activate
24-
pip install --use-feature=2020-resolver -r requirements.txt -r requirements-dev.txt
30+
pip install -e ".[dev]"
2531
```
2632

2733
### Common Commands
@@ -38,7 +44,7 @@ inv dist # build distribution packages
3844
inv release # upload the current version to pypi
3945
```
4046

41-
## Release Process
47+
### Release Process
4248

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

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 commit comments

Comments
 (0)