Skip to content

Commit

Permalink
Update GH actions release workflow (#145)
Browse files Browse the repository at this point in the history
Notes:
- added changes for poetry build cycle and push to test-pypi
- updated test_cov script to properly fail with failed tests

---------

Co-authored-by: Tyler Hutcherson <tyler.hutcherson@redis.com>
  • Loading branch information
rbs333 and tylerhutcherson authored May 1, 2024
1 parent 7faaf4e commit d7526b5
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

name: check
name: Lint

on:
pull_request:
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/publish.yml

This file was deleted.

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

on:
workflow_dispatch:
inputs:
version:
description: 'Version of this deployment'
required: true

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.4.2"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Set Version
run: poetry version ${{ github.event.inputs.version }}

- name: Build package
run: poetry build

- name: Upload build
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

# test-pypi-publish:
# needs: build
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}

# - name: Install Poetry
# uses: snok/install-poetry@v1

# - uses: actions/download-artifact@v4
# with:
# name: dist
# path: dist/

# - name: Publish to TestPyPI
# env:
# POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TESTPYPI }}
# run: poetry config repositories.test-pypi https://test.pypi.org/legacy/; poetry config pypi-token.test-pypi $POETRY_PYPI_TOKEN_TESTPYPI; poetry publish --repository test-pypi

# pre-release-checks:
# needs: test-pypi-publish
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}

# - name: Install Poetry
# uses: snok/install-poetry@v1

# - name: Install dependencies
# run: |
# poetry install --all-extras

# - name: Install published package from TestPyPI
# env:
# OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }}
# GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
# GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
# COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
# AZURE_OPENAI_API_KEY: ${{secrets.AZURE_OPENAI_API_KEY}}
# AZURE_OPENAI_ENDPOINT: ${{secrets.AZURE_OPENAI_ENDPOINT}}
# AZURE_OPENAI_DEPLOYMENT_NAME: ${{secrets.AZURE_OPENAI_DEPLOYMENT_NAME}}
# OPENAI_API_VERSION: ${{secrets.OPENAI_API_VERSION}}
# run:
# poetry run pip install --index-url https://test.pypi.org/simple/ --no-deps redisvl-test; poetry run test-cov

publish:
needs: build #pre-release-checks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

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

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI }}
run: poetry publish

create-release:
needs: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
generateReleaseNotes: true
tag: ${{ github.event.inputs.version }}
commit: main
46 changes: 0 additions & 46 deletions .github/workflows/test-publish.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ scratch
wiki_schema.yaml
docs/_build/
.venv
coverage.xml
coverage.xml
dist/
22 changes: 11 additions & 11 deletions scripts.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import subprocess

def format():
subprocess.run(["isort", "./redisvl", "./tests/", "--profile", "black"])
subprocess.run(["black", "./redisvl", "./tests/"])
subprocess.run(["isort", "./redisvl", "./tests/", "--profile", "black"], check=True)
subprocess.run(["black", "./redisvl", "./tests/"], check=True)

def check_format():
subprocess.run(["black", "--check", "./redisvl"])
subprocess.run(["black", "--check", "./redisvl"], check=True)

def sort_imports():
subprocess.run(["isort", "./redisvl", "./tests/", "--profile", "black"])
subprocess.run(["isort", "./redisvl", "./tests/", "--profile", "black"], check=True)

def check_sort_imports():
subprocess.run(["isort", "./redisvl", "--check-only", "--profile", "black"])
subprocess.run(["isort", "./redisvl", "--check-only", "--profile", "black"], check=True)

def check_lint():
subprocess.run(["pylint", "--rcfile=.pylintrc", "./redisvl"])
subprocess.run(["pylint", "--rcfile=.pylintrc", "./redisvl"], check=True)

def mypy():
subprocess.run(["python", "-m", "mypy", "./redisvl"])
subprocess.run(["python", "-m", "mypy", "./redisvl"], check=True)

def test():
subprocess.run(["python", "-m", "pytest", "--log-level=CRITICAL"])
subprocess.run(["python", "-m", "pytest", "--log-level=CRITICAL"], check=True)

def test_verbose():
subprocess.run(["python", "-m", "pytest", "-vv", "-s", "--log-level=CRITICAL"])
subprocess.run(["python", "-m", "pytest", "-vv", "-s", "--log-level=CRITICAL"], check=True)

def test_cov():
subprocess.run(["python", "-m", "pytest", "-vv", "--cov=./redisvl", "--cov-report=xml", "--log-level=CRITICAL"], check=True)

def cov():
subprocess.run(["coverage", "html"])
subprocess.run(["coverage", "html"], check=True)
print("If data was present, coverage report is in ./htmlcov/index.html")

def test_notebooks():
subprocess.run(["cd", "docs/", "&&", "poetry run treon", "-v"])
subprocess.run(["cd", "docs/", "&&", "poetry run treon", "-v"], check=True)

def build_docs():
subprocess.run("cd docs/ && make html", shell=True)
Expand Down

0 comments on commit d7526b5

Please sign in to comment.