Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
QPT-36078 Updated template
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrake committed Aug 2, 2021
1 parent c9ecb39 commit 0ec9dcc
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 47 deletions.
39 changes: 39 additions & 0 deletions .circleci/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Bump the Python package version via Poetry then commit and push back to the branch
# Usage: ./bump-version.sh main my-new-branch
set -eo pipefail

BASE_BRANCH="$1"
NEW_BRANCH="$2"

git checkout "$BASE_BRANCH"
baseVersion="$(poetry version -s)"
git checkout "$NEW_BRANCH"
branchVersion="$(poetry version -s)"
result="$(python - "$baseVersion" "$branchVersion" <<EOF
from packaging.version import parse
import sys
base_version = parse(sys.argv[1])
branch_version = parse(sys.argv[2])
if branch_version > base_version:
print("1")
elif branch_version < base_version:
print("-1")
else:
print("0")
EOF
)"
if [[ "$result" == "1" ]]; then
echo "Branch version is newer than the base. Continuing..."
elif [[ "$result" == "-1" ]]; then
echo "Branch version is older than the base. Failing..."
exit 1
else
echo "Branch version matches the base. Bumping..."
poetry version minor
branchVersion="$(poetry version -s)"
sed -E -i "s/__version__ = \"[0-9\.]+\"/__version__ = \"${branchVersion}\"/" */__init__.py
git add pyproject.toml */__init__.py
git commit -m "Version bumped to ${branchVersion}"
git push --set-upstream origin "$NEW_BRANCH"
fi
55 changes: 32 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ version: 2.1
orbs:
aws-cli: circleci/[email protected]
ghpr: narrativescience/[email protected]
github-cli: circleci/[email protected]

jobs:
test:
docker:
- image: cimg/python:3.6
commands:
configure-poetry:
description: Configure Poetry
steps:
- aws-cli/install
- ghpr/build-prospective-branch
- run:
name: Install dependencies
name: Configure Poetry
command: |
pip install -U pip setuptools
pip install poetry
Expand All @@ -24,8 +22,31 @@ jobs:
--output text)"
poetry config repositories.codeartifact "$CODEARTIFACT_URL"
poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN"
release:
steps:
- github-cli/setup
- run:
name: Create GitHub Release
command: |
version="$(poetry version -s)"
notes="$(git show -s --format=%B HEAD)"
gh release create "v${version}" --title "Version ${version}" --notes "$notes"
poetry install
jobs:
test:
docker:
- image: cimg/python:3.6
steps:
- add_ssh_keys:
fingerprints:
- "cb:4c:e2:f4:c2:be:b7:c0:1a:02:1b:13:15:e0:a4:1b"
- ghpr/build-prospective-branch
- aws-cli/install
- configure-poetry
- run:
name: Bump version
command: .circleci/bump-version.sh "$GITHUB_PR_BASE_BRANCH" "$CIRCLE_BRANCH"
- run: poetry install
- run:
name: Run commit hooks
command: |
Expand All @@ -47,21 +68,11 @@ jobs:
steps:
- aws-cli/install
- checkout
- run: pip install poetry
- configure-poetry
- run: poetry install
- run: poetry build
- run:
name: Configure private package repository
command: |
export CODEARTIFACT_AUTH_TOKEN="$(
aws codeartifact get-authorization-token \
--domain lexio \
--domain-owner "$AWS_ACCOUNT_ID" \
--query authorizationToken \
--output text)"
poetry config repositories.codeartifact "$CODEARTIFACT_URL"
poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN"
- run: poetry publish -r codeartifact
- release

workflows:
pull_request:
Expand All @@ -77,7 +88,5 @@ workflows:
- publish:
context: lexio-package
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
only: main
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exclude: "examples/.*$"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v4.0.1
hooks:
- id: check-ast
- id: check-builtin-literals
Expand Down Expand Up @@ -46,7 +46,7 @@ repos:
entry: black
language: python
types: [file, python]
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==21.7b0]

- id: pydocstyle
name: Lint Python docstrings (pydocstyle)
Expand Down
18 changes: 1 addition & 17 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
Copyright (c) 2021, Narrative Science

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
modification, are NOT permitted.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ns_sql_utils

Utilities for interacting with sql databases
Utilities for interacting with SQL databases

Features:

Expand Down
2 changes: 1 addition & 1 deletion ns_sql_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Utilities for interacting with sql databases"""
"""Utilities for interacting with SQL databases"""

__version__ = "0.1.0"
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tool.poetry]
name = "ns_sql_utils"
version = "0.1.0"
description = "Utilities for interacting with sql databases"
description = "Utilities for interacting with SQL databases"
authors = ["Gregory Berns-Leone <[email protected]>"]
license = "BSD-3-Clause"
license = "Proprietary"
readme = "README.md"
homepage = "https://github.com/NarrativeScience/ns_sql_utils"
repository = "https://github.com/NarrativeScience/ns_sql_utils"
Expand All @@ -14,7 +14,7 @@ python = "^3.6.5"
[tool.poetry.dev-dependencies]
pre-commit = "^2.10.1"
pytest = "^6.2.2"

black = {version = "^21.7b0", allow-prereleases = true}

[[tool.poetry.source]]
name = "codeartifact"
Expand Down

0 comments on commit 0ec9dcc

Please sign in to comment.