Skip to content

Commit

Permalink
Setup build and test
Browse files Browse the repository at this point in the history
  • Loading branch information
narenst committed May 10, 2024
1 parent ce372e3 commit bce80aa
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Publish Python Package

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out the code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install wheel
- name: Build package
run: python -m build

- name: Upload Python Package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
15 changes: 15 additions & 0 deletions bin/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
set -o pipefail

if [ -z "${VIRTUAL_ENV}" ]; then
# Create a local virtualenv if one does not exist
test -d .venv || python3 -m venv .venv --prompt random-real-addresses
source .venv/bin/activate
fi

# We need wheel to install any binary packagess
pip3 install --disable-pip-version-check wheel

# Install dependencies in editable mode
pip3 install --disable-pip-version-check --editable '.[dev]'
9 changes: 9 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
set -o pipefail

if [ -z "${VIRTUAL_ENV}" ] && [ -r .venv ]; then
source .venv/bin/activate
fi

pytest .
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "random-real-address"
version = "0.1.0"
description = "A Python package to generate real addresses in the US."
authors = [{name = "Naren Thiagarajan", email = "narenst@gmail.com"}]
license = {text = "MIT License"}
dependencies = []

[project.optional-dependencies]

dev = [
"pytest==6.2.4",
"flake8==3.9.2",
"black==21.9b0",
]

[tool.setuptools.packages.find]
where = ["random_address"]
3 changes: 3 additions & 0 deletions random_address/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .generator import generate_random_address

__all__ = ['generate_random_address']
2 changes: 2 additions & 0 deletions random_address/generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def generate_random_address():
return '1234 Elm St.'
52 changes: 52 additions & 0 deletions state_abbreviations_mapping.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
state,abbreviation
Alabama,AL
Alaska,AK
Arizona,AZ
Arkansas,AR
California,CA
Colorado,CO
Connecticut,CT
Delaware,DE
District of Columbia,DC
Florida,FL
Georgia,GA
Hawaii,HI
Idaho,ID
Illinois,IL
Indiana,IN
Iowa,IA
Kansas,KS
Kentucky,KY
Louisiana,LA
Maine,ME
Maryland,MD
Massachusetts,MA
Michigan,MI
Minnesota,MN
Mississippi,MS
Missouri,MO
Montana,MT
Nebraska,NE
Nevada,NV
New Hampshire,NH
New Jersey,NJ
New Mexico,NM
New York,NY
North Carolina,NC
North Dakota,ND
Ohio,OH
Oklahoma,OK
Oregon,OR
Pennsylvania,PA
Rhode Island,RI
South Carolina,SC
South Dakota,SD
Tennessee,TN
Texas,TX
Utah,UT
Vermont,VT
Virginia,VA
Washington,WA
West Virginia,WV
Wisconsin,WI
Wyoming,WY
Empty file added tests/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unittest

from random_address import generate_random_address

class TestRandomAddress(unittest.TestCase):
def test_generate_random_address(self):
address = generate_random_address()
self.assertTrue(isinstance(address, str))
self.assertGreater(len(address), 0)

0 comments on commit bce80aa

Please sign in to comment.