Skip to content

Commit

Permalink
Merge pull request #35 from BurnySc2/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnySc2 authored Dec 6, 2023
2 parents dad4721 + 6279289 commit f848bd3
Show file tree
Hide file tree
Showing 552 changed files with 33,677 additions and 95,910 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/earthly_project_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: run_earthly_checks


on: [push, pull_request]

jobs:
run_earthly_checks:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

# In conflict with pyre-check
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Cache burny_common .venv
# uses: actions/cache@v3
# with:
# path: burny_common/.venv
# key: burny_common-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
#
# - name: Cache discord_bot .venv
# uses: actions/cache@v3
# with:
# path: discord_bot/.venv
# key: discord_bot-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
#
# - name: Cache fastapi_server .venv
# uses: actions/cache@v3
# with:
# path: fastapi_server/.venv
# key: fastapi_server-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
#
# - name: Cache python_examples .venv
# uses: actions/cache@v3
# with:
# path: python_examples/.venv
# key: python_examples-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}

# https://earthly.dev/get-earthly
- name: Install Earthly
run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'

- name: Install
run: |
touch discord_bot/SECRETS.toml
earthly +install-all --verbose true --PYTHONVERSION=${{ matrix.python-version }}
- name: Run code checks and tests
run: earthly +all --verbose true --PYTHONVERSION=${{ matrix.python-version }}

# - name: Save cache
# run: earthly +export-cache-backend --verbose true --PYTHONVERSION=${{ matrix.python-version }}
110 changes: 110 additions & 0 deletions .github/workflows/publish_burny_common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: publish_burny_common


on:
push:
paths:
- burny_common/**
- .github/workflows/publish_burny_common.yml
pull_request:
branches:
- master
- develop

env:
SUBDIRECTORY: burny_common

jobs:
run_code_check:
name: run_code_check_py${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

# In conflict with pyre-check
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Cache .venv
# uses: actions/cache@v3
# with:
# path: .venv
# key: ${{ env.SUBDIRECTORY }}-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}

# https://earthly.dev/get-earthly
- name: Install Earthly
run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'

- name: Install
working-directory: ${{ env.SUBDIRECTORY }}
run: earthly +install-dev --verbose true --PYTHONVERSION=${{ matrix.python-version }}

- name: Run code checks and tests
working-directory: ${{ env.SUBDIRECTORY }}
run: earthly +all --verbose true --PYTHONVERSION=${{ matrix.python-version }}

# - name: Save cache
# working-directory: ${{ env.SUBDIRECTORY }}
# run: earthly +export-cache --verbose true --PYTHONVERSION=${{ matrix.python-version }}

build_and_publish:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.10']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

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

- name: Install Poetry
run: pip install poetry

- name: Make poetry use local .venv folder
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v3
with:
path: ${{ env.SUBDIRECTORY }}/.venv
key: ${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ env.SUBDIRECTORY }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
working-directory: ${{ env.SUBDIRECTORY }}
run: poetry install --no-dev

- name: Build
working-directory: ${{ env.SUBDIRECTORY }}
run: poetry build

- id: wait-for-jobs
uses: yogeshlonkar/wait-for-jobs@v0
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
jobs: |
run_code_check_py3.8
run_code_check_py3.9
run_code_check_py3.10
run_code_check_py3.11
# Publish package on pypi
- name: Publish
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
working-directory: ${{ env.SUBDIRECTORY }}
continue-on-error: true
run: poetry publish --username ${{ secrets.pypi_username }} --password ${{ secrets.pypi_password }}
54 changes: 0 additions & 54 deletions .github/workflows/publish_example_package.yml

This file was deleted.

131 changes: 97 additions & 34 deletions .github/workflows/python_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,132 @@ on:
paths:
- python_examples/**
- poetry.lock
- .github/workflows/python_examples.yml
pull_request:
branches:
- master
- develop

env:
SUBDIRECTORY: python_examples

jobs:
run_code_check:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

# In conflict with pyre-check
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Cache .venv
# uses: actions/cache@v3
# with:
# path: .venv
# key: ${{ env.SUBDIRECTORY }}-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Start MongoDB
uses: ankane/setup-mongodb@v1

- name: Start Postgres
uses: ankane/setup-postgres@v1
with:
postgres-version: 14

# https://earthly.dev/get-earthly
- name: Install Earthly
run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'

- name: Install
working-directory: ${{ env.SUBDIRECTORY }}
run: earthly +install-dev --verbose true --PYTHONVERSION=${{ matrix.python-version }}

- name: Run code checks and tests
working-directory: ${{ env.SUBDIRECTORY }}
run: earthly +all --verbose true --PYTHONVERSION=${{ matrix.python-version }}

# - name: Save cache
# working-directory: ${{ env.SUBDIRECTORY }}
# run: earthly +export-cache --verbose true --PYTHONVERSION=${{ matrix.python-version }}

run_python_examples:
env:
SUBDIRECTORY: python_examples
needs: [run_code_check]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10']
mongodb-version: [5.0.0]
python-version: ['3.9', '3.10', '3.11']
include:
- os: macos-latest
python-version: '3.10'
- os: windows-latest
python-version: '3.10'

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Cache poetry
uses: actions/cache@v2
- name: Install Poetry
run: pip install poetry

- name: Make poetry use local .venv folder
run: poetry config virtualenvs.in-project true

- name: Set up cache
if: matrix.os != 'windows-latest'
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
path: ${{ env.SUBDIRECTORY }}.venv
key: ${{ matrix.os }}-$(python --version)-poetry-${{ env.SUBDIRECTORY }}-${{ hashFiles('poetry.lock') }}

- name: Start MongoDB in docker
run: |
docker run --rm -d -p 27017-27019:27017-27019 --name mongodb mongo:${{ matrix.mongodb-version }}
- name: Start MongoDB
uses: ankane/setup-mongodb@v1
# with:
# mongodb-version: 5.0

- name: Start Postgres in docker
run: |
docker run --rm -d --name postgresql-container -p 5432:5432 \
-e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=changeme postgres:9.6.23-alpine3.14
# - name: Start MongoDB in docker
# if: ${{ matrix.os != 'macos-latest'}}
# run: |
# docker run --rm -d -p 27017-27019:27017-27019 --name mongodb mongo:5.0

- uses: actions/cache@v2
- name: Start Postgres
uses: ankane/setup-postgres@v1
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
postgres-version: 14

# - name: Start Postgres in docker
# if: ${{ matrix.os == 'ubuntu-latest'}}
# run: |
# docker run --rm -d --name postgresql-container -p 5432:5432 \
# -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=changeme postgres:9.6.23-alpine3.14

- name: Print environment variables (linux)
run: |
printenv
- name: Install dependencies
run: |
python -m pip install poetry
poetry install
- name: Install Python dependencies
working-directory: ${{ env.SUBDIRECTORY }}
run: poetry install

- name: Test with pytest
run: |
poetry run pytest ${{ env.SUBDIRECTORY }}
- name: Run Python tests
working-directory: ${{ env.SUBDIRECTORY }}
run: poetry run python -m pytest

- name: Run main.py
run: |
poetry run python ${{ env.SUBDIRECTORY }}/main.py
- name: Run radon (cyclomatic complexity report)
# './' denotes the current directory
run: |
poetry run radon cc ./ -a -nb
working-directory: ${{ env.SUBDIRECTORY }}
run: poetry run python main.py
Loading

0 comments on commit f848bd3

Please sign in to comment.