refactor in the class StreamlitHandler #2709
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: [push] | |
jobs: | |
ci-cd: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
# Compare requirement files | |
- name: Compare requirement files | |
run: | | |
# Extract requirements from setup.cfg, remove leading spaces, and store in req_compare.txt | |
sed -n '/install_requires/,/^\[/{//!p}' setup.cfg | awk '/^ *$/ { next; } { print; }' | sed 's/^ //' > req_compare.txt | |
# Compare req_compare.txt with requirements.txt | |
# If files are different, echo the differences and exit with error status | |
if DIFF=$(diff req_compare.txt requirements.txt) ; then | |
echo "Files are the same" | |
else | |
echo "Files are different:" | |
diff req_compare.txt requirements.txt | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: | | |
sudo apt install python3.9-venv -y | |
python -m pip install --upgrade pip | |
pip install flake8 pytest build | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
# - name: Test with pytest | |
# run: | | |
# pytest | |
- name: Build Package | |
run: | | |
python3 -m build . | |
- name: Publish package | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} # For testing purposes: use secrets.PYPI_TEST_TOKEN | |
print_hash: true | |
verbose: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: tdspora | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Docker meta (BASE) | |
id: docker_meta_base | |
uses: crazy-max/ghaction-docker-meta@v1 | |
with: | |
images: tdspora/syngen | |
tag-custom: ${{ github.ref == 'refs/heads/main' && 'latest' || '' }} | |
tag-semver: | | |
{{raw}} | |
- name: Build and push (BASE) | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.docker_meta_base.outputs.tags }} | |
labels: ${{ steps.docker_meta_base.outputs.labels }} | |
cache-from: type=registry,ref=tdspora/syngen:buildcache | |
cache-to: type=registry,ref=tdspora/syngen:buildcache,mode=max |