Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…next
  • Loading branch information
F33RNI committed Dec 19, 2023
2 parents 26f6cb9 + ef5580b commit 84dcda2
Show file tree
Hide file tree
Showing 20 changed files with 743 additions and 214 deletions.
97 changes: 97 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Git
.git
.gitignore
.gitattributes

# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml

# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Virtual environment
.env
.venv/
venv/

# PyCharm
.idea

# Python mode for VIM
.ropeproject
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
.vscode/

# GitHub
.github/

# Documents
README.md
Screenshots/
Banner.png
Logo.png
129 changes: 97 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,106 @@ on:
push:
branches:
- '*'
tags:
- '*'

jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- os: linux
arch: amd64
- os: linux
arch: arm64

runs-on: ubuntu-latest

steps:
- id: lowercaseRepo
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Check out code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create short sha and tag
shell: bash
run: |
echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then echo TAG=latest; else echo TAG="${GITHUB_REF##*/}"; fi >> $GITHUB_ENV
- name: Build Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }}
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.TAG }}
platforms: linux/amd64, linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- id: lowercaseRepo
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}
- name: Build Docker Image
id: build
uses: docker/build-push-action@v5
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platform.os }}/${{ matrix.platform.arch }}
outputs: type=image,name=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- id: lowercaseRepo
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=auto
tags: |
type=edge,branch=next
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
images: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(find -maxdepth 2 -mindepth 2 -type f -printf "ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}@sha256:%f ")
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.meta.outputs.version }}
20 changes: 11 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ jobs:
strategy:
matrix:
platform:
- amd64
- arm64
- os: linux
arch: amd64
- os: linux
arch: arm64

runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v2
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: telegramus-test-${{ matrix.platform }}
platforms: linux/${{ matrix.platform }}
tags: telegramus-test-${{ matrix.platform.os }}-${{ matrix.platform.arch}}
platforms: ${{ matrix.platform.os }}/${{ matrix.platform.arch}}
- run: |
docker run --rm "telegramus-test-${{ matrix.platform }}" /app/telegramus --version
docker run --rm "telegramus-test-${{ matrix.platform.os }}-${{ matrix.platform.arch}}" /app/telegramus --version
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ data/
Banner.psd
Banner.tif
UsersRecover.py
venv
__pycache__
4 changes: 0 additions & 4 deletions BardModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ def process_request(self, request_response: RequestResponseContainer) -> None:
response_id = UsersHandler.get_key_or_none(request_response.user, "bard_response_id")
choice_id = UsersHandler.get_key_or_none(request_response.user, "bard_choice_id")

# Increment requests_total for statistics
request_response.user["requests_total"] += 1
self.users_handler.save_user(request_response.user)

# Try to load conversation
if conversation_id and response_id and choice_id:
logging.info("Using conversation_id: {}, response_id: {} and choice_id: {}".format(conversation_id,
Expand Down
4 changes: 0 additions & 4 deletions BingImageGenModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ def process_request(self, request_response: RequestResponseContainer) -> None:
return

try:
# Increment requests_total for statistics
request_response.user["requests_total"] += 1
self.users_handler.save_user(request_response.user)

# Generate images
logging.info("Requesting images from Bing ImageGen")
response_urls = self._image_generator.get_images(request_response.request)
Expand Down
Loading

0 comments on commit 84dcda2

Please sign in to comment.