Skip to content

Commit

Permalink
Dev Ops Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkStarStrix committed Nov 14, 2024
1 parent 848760c commit b4ad847
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
32 changes: 21 additions & 11 deletions .github/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[tool.black]
line-length = 88
target-version = ['py39']
include = '\.pyi?$'
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
^/docs
'''

[tool.isort]
profile = "black"
Expand All @@ -12,26 +16,32 @@ use_parentheses = true
ensure_newline_before_comments = true
line_length = 88

[tool.pylint.messages_control]
[tool.pylint.'MESSAGES CONTROL']
disable = [
"C0111", # missing-docstring
"C0103", # invalid-name
"C0303", # trailing-whitespace
"C0330", # wrong-hanging-indentation
"C0326", # bad-whitespace
"W0621", # redefined-outer-name
"R0903", # too-few-public-methods
"R0913", # too-many-arguments
"W0511",
]

[tool.pylint.FORMAT]
max-line-length = 88

[tool.mypy]
python_version = "3.9"
warn_return_any = true
warn_unused_configs = true
ignore_missing_imports = true
follow_imports = "silent"
disallow_untyped_defs = false
disallow_incomplete_defs = false

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
]

[tool.bandit]
exclude_dirs = ["tests", "venv", ".env"]
skips = ["B101"]
testpaths = ["tests"]
python_files = ["test_*.py"]
addopts = "-ra -q --cov=. --cov-report=xml"
45 changes: 27 additions & 18 deletions .github/workflows/main_2.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -34,31 +33,37 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8 isort mypy pylint bandit
pip install black==23.3.0 flake8==6.0.0 isort==5.12.0 mypy==1.3.0 pylint==2.17.3 bandit==1.7.5
pip install -r requirements.txt
- name: Run black
run: black . --check
run: |
black . --check --diff || (echo "Please run 'black .' to format your code" && exit 1)
- name: Run flake8
run: flake8 .
run: |
flake8 . --count --show-source --statistics || (echo "Please fix the flake8 issues" && exit 1)
- name: Run isort
run: isort . --check-only
run: |
isort . --check-only --diff || (echo "Please run 'isort .' to sort your imports" && exit 1)
- name: Run mypy
run: mypy .
run: |
mypy . || (echo "Please fix type hints according to mypy" && exit 1)
- name: Run pylint
run: pylint **/*.py
continue-on-error: true
run: |
pylint **/*.py || echo "Pylint checks completed with warnings"
- name: Run bandit
run: bandit -r .
run: |
bandit -r . -c pyproject.toml || (echo "Please fix security issues found by bandit" && exit 1)
security-scan:
name: Security Scan
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -70,13 +75,16 @@ jobs:
- name: Install security tools
run: |
python -m pip install --upgrade pip
pip install safety bandit
pip install safety==2.3.5 bandit==1.7.5
- name: Check dependencies for known vulnerabilities
run: safety check
continue-on-error: true
run: |
safety check || echo "Safety checks completed with warnings"
- name: Run security linter
run: bandit -r . -c pyproject.toml
run: |
bandit -r . -c pyproject.toml || (echo "Please fix security issues found by bandit" && exit 1)
test:
name: Run Tests
Expand All @@ -96,26 +104,27 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-asyncio httpx
pip install pytest==7.4.3 pytest-cov==4.1.0 pytest-asyncio==0.21.1 httpx==0.24.1
pip install -r requirements.txt
- name: Run tests with coverage
env:
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
VALID_API_KEY: ${{ secrets.VALID_API_KEY }}
run: |
pytest --cov=. --cov-report=xml
pytest --cov=. --cov-report=xml --cov-report=term-missing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: true

build-and-push:
name: Build and Push Docker Image
needs: [code-quality, security-scan, test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/master'

steps:
- uses: actions/checkout@v3
Expand All @@ -136,15 +145,15 @@ jobs:
uses: docker/build-push-action@v4
with:
push: true
tags: yourusername/automl-api:latest,yourusername/automl-api:${{ github.sha }}
cache-from: type=registry,ref=yourusername/automl-api:latest
tags: ${{ secrets.DOCKERHUB_USERNAME }}/automl-api:latest,${{ secrets.DOCKERHUB_USERNAME }}/automl-api:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/automl-api:latest
cache-to: type=inline

deploy:
name: Deploy
needs: build-and-push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/master'

steps:
- name: Deploy to production
Expand Down
1 change: 1 addition & 0 deletions Templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
headers: { 'Authorization': `Bearer ${token}` }
});
const data = await response.json();
data.templates = undefined;
setTemplates(data.templates);
} catch (err) {
setError('Failed to fetch templates');
Expand Down

0 comments on commit b4ad847

Please sign in to comment.