Skip to content

Commit

Permalink
Merge pull request #236 from Boavizta/dev
Browse files Browse the repository at this point in the history
Merging v1 into main
  • Loading branch information
da-ekchajzer authored Oct 10, 2023
2 parents 5b6ef42 + cb08e11 commit 93d803e
Show file tree
Hide file tree
Showing 192 changed files with 57,577 additions and 7,260 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/build_client.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
name: build_client_sdk

on:
push:
tags:
- '*'
paths-ignore:
- 'docs/**'
- 'test/**'
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
- 'Dockerfile'
- 'CITATION'
- 'book.toml'
- 'CONTRIBUTING.md'
# Disable automatic triggring of this legacy workflow (replaced by build_client_sdk_with_poetry)
on: workflow_dispatch

# on:
# push:
# tags:
# - '*'
# paths-ignore:
# - 'docs/**'
# - 'test/**'
# - 'README.md'
# - 'CHANGELOG.md'
# - 'LICENSE'
# - 'Dockerfile'
# - 'CITATION'
# - 'book.toml'
# - 'CONTRIBUTING.md'

env:
CARGO_TERM_COLOR: always
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/build_client_sdk_with_poetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: build_client_sdk_with_poetry

on:
push:
tags:
- '*'
paths-ignore:
- 'docs/**'
- 'test/**'
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
- 'Dockerfile'
- 'CITATION'
- 'book.toml'
- 'CONTRIBUTING.md'

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: build_python_client_sdk
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install pipenv
run: |
python -m pip install --upgrade poetry wheel twine
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
make install
- name: Build local api package
run: make build

- name: Build the api Docker image
run: docker build --build-arg VERSION=$(poetry version -s) . --file Dockerfile --tag boaviztapi:latest

- name: Run the API locally
run: |
docker run -p "5000:5000" --name=boaviztapi -tid boaviztapi:latest
- name: Get logs from the API container in case of a failure
run: |
docker logs boaviztapi
- name: Get the openapi.json definition and generate the code
run: |
while [[ ! $(docker ps | grep boaviztapi) ]]; do sleep 1; echo "Waiting for BoaviztAPI container to boot"; done
wget http://127.0.0.1:5000/openapi.json
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/openapi.json -g python -o /local/boaviztapi_sdk --package-name boaviztapi_sdk
# Publish client SDK package
- name: Build the pip package and push it
run: |
sudo chown -R $(whoami) boaviztapi_sdk
SDK_VERSION=$(poetry version -s)
echo "SDK_VERSION == ${SDK_VERSION}"
cd boaviztapi_sdk
sed -i "s/^VERSION.*/VERSION = \"${SDK_VERSION}\"/" setup.py
sed -i "s/^ long_description=.*/ long_description='Python SDK for boaviztAPI',/" setup.py
sed -i '/ <p>.*/d' setup.py
sed -i '/ """.*/d' setup.py
python3 setup.py sdist
# Publish
pip3 install pipenv twine
pipenv run twine upload --repository pypi --username __token__ --password ${{ secrets.BPETIT_SECRET_PYPI_TOKEN }} dist/*
17 changes: 7 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
python -m pip install --upgrade poetry wheel
- id: cache-pipenv
uses: actions/cache@v1
Expand All @@ -41,19 +41,16 @@ jobs:
- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
make install
- name: Build the pip package
run: python3 setup.py sdist

- name: push pip package
run: pipenv run twine upload --repository pypi --username __token__ --password ${{ secrets.DAVID_PYPI_TOKEN }} dist/*
- name: Push package on pypi
run: API_TOKEN=${{ secrets.DAVID_PYPI_TOKEN }} make distribute

- name: Build the api Docker image
run: docker build --build-arg VERSION=$(python setup.py --version) . --file Dockerfile --tag ghcr.io/boavizta/boaviztapi:latest
run: docker build --build-arg VERSION=$(poetry version -s) . --file Dockerfile --tag ghcr.io/boavizta/boaviztapi:latest

- name : Tag api Docker image
run: docker tag ghcr.io/boavizta/boaviztapi:latest ghcr.io/boavizta/boaviztapi:$(python setup.py --version)
run: docker tag ghcr.io/boavizta/boaviztapi:latest ghcr.io/boavizta/boaviztapi:$(poetry version -s)

- name: Push api images
run: docker push -a ghcr.io/boavizta/boaviztapi
Expand All @@ -62,7 +59,7 @@ jobs:
run: docker build docs --file docs/Dockerfile --tag ghcr.io/boavizta/boaviztapi-doc:latest

- name: Tag doc the Docker image
run: docker tag ghcr.io/boavizta/boaviztapi-doc:latest ghcr.io/boavizta/boaviztapi-doc:$(python setup.py --version)
run: docker tag ghcr.io/boavizta/boaviztapi-doc:latest ghcr.io/boavizta/boaviztapi-doc:$(poetry version -s)

- name: Push doc images
run: docker push -a ghcr.io/boavizta/boaviztapi-doc
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ on:
- dev
paths:
- 'boaviztapi/**'
- 'tests/**'
pull_request:
paths:
- 'boaviztapi/**'
- 'tests/**'
branches:
- main
- dev
Expand All @@ -26,12 +28,12 @@ jobs:

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
python -m pip install --upgrade poetry wheel
- name: Install dependencies
run: |
pipenv install --dev
make install
- name: Run test suite
run: |
pipenv run pytest
make test
36 changes: 24 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CURRENT_VERSION ?= `pipenv run python setup.py --version`
CURRENT_VERSION := $(shell poetry version -s)
DOCKER_NAME := boavizta/boaviztapi:${CURRENT_VERSION}
SEMVERS := major minor patch

clean:
find . -name "*.pyc" -exec rm -rf {} \;
Expand All @@ -7,24 +9,34 @@ clean:
install: install_pip

install_pip:
pipenv install -d
poetry install --with dev

test:
pipenv run pytest
poetry run pytest

run:
pipenv run uvicorn boaviztapi.main:app
poetry run uvicorn boaviztapi.main:app

minor:
pipenv run bumpversion --commit --tag --current-version ${CURRENT_VERSION} minor boaviztapi/__init__.py
$(SEMVERS):
poetry version $@
$(MAKE) npm_version
$(MAKE) tag_version

major:
pipenv run bumpversion --commit --tag --current-version ${CURRENT_VERSION} major boaviztapi/__init__.py
npm_version:
npm version --no-git-tag-version ${CURRENT_VERSION}

patch:
pipenv run bumpversion --commit --tag --current-version ${CURRENT_VERSION} patch boaviztapi/__init__.py

tag_version:
git commit -m "release: bump to ${CURRENT_VERSION}" pyproject.toml package.json package-lock.json
git tag ${CURRENT_VERSION}

build:
poetry build

distribute:
pipenv run python setup.py sdist bdist_wheel
pipenv run twine upload dist/*
poetry config pypi-token.pypi ${API_TOKEN}
poetry publish --build

docker-build:
docker build -t $(DOCKER_NAME) . --build-arg VERSION=${CURRENT_VERSION}

32 changes: 0 additions & 32 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 93d803e

Please sign in to comment.