Skip to content

Commit

Permalink
Update lint, security/type checks to use docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ayhamthemayhem committed Jul 17, 2024
1 parent 05090a5 commit 228f68d
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 414 deletions.
41 changes: 21 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
name: CI

on:
- push
- pull_request
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.11]
include:
- name: Lint
command: make lint
- name: Reformat
command: make reformat
- name: Type-Check
command: make type-check
- name: Security-Check
command: make security-check

steps:
- name: Check out repository
uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-ignore-env-name-mismatch
pip install -r requirements.txt
- name: Run lint
run: tox -e lint

- name: Run reformat
run: tox -e reformat

- name: Run type-check
run: tox -e type-check

- name: Run security-check
run: tox -e security-check
pip install -r requirements/dev.txt
- name: Run ${{ matrix.name }}
run: ${{ matrix.command }}
26 changes: 7 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lint reformat type-check security-check \
start stop rebuild destroy \
migrate create-admin \
routes install-deps install-tox
routes

default:
@echo "Call a specific subcommand:"
Expand All @@ -14,24 +14,6 @@ default:
@echo
@exit 1

install-deps:
pip install -r requirements.txt

install-tox:
pip install tox

lint: install-tox
tox -e lint

reformat: install-tox
tox -e reformat

type-check: install-tox
tox -e type-check

security-check: install-tox
tox -e security-check

start:
docker-compose up --build --detach

Expand Down Expand Up @@ -60,3 +42,9 @@ reformat:

lint:
docker compose run --build --rm base bin/lint

security-check:
docker compose run --build --rm base bandit -c pyproject.toml -r .

type-check:
docker compose run --build --rm base mypy --config-file pyproject.toml .
1 change: 0 additions & 1 deletion bandit.yaml

This file was deleted.

9 changes: 2 additions & 7 deletions cabotage/server/models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,7 @@ def deposed_reason(self):
).first()
if configuration_object is None:
reasons.append(
f"<code>Configuration for {
configuration} no longer exists!</code>"
f"<code>Configuration for {configuration} no longer exists!</code>"
)
return reasons

Expand Down Expand Up @@ -542,11 +541,7 @@ def envconsul_configurations(self):
configurations["shell"] = "\n".join([exec_statement, environment_statements])
for proc_name, proc in self.image_object.processes.items():
custom_env = json.dumps([f"{key}={value}" for key, value in proc["env"]])
exec_statement = (
"exec {\n"
f' command = {
json.dumps(proc["cmd"])}\n'
)
exec_statement = "exec {\n" f' command = {json.dumps(proc["cmd"])}\n'
if not self.application.privileged:
exec_statement += (
" env = {\n"
Expand Down
5 changes: 0 additions & 5 deletions mypy.ini

This file was deleted.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.bandit]
exclude_dirs = ["bin", "lib"]

[tool.mypy]
ignore_missing_imports = true
Loading

0 comments on commit 228f68d

Please sign in to comment.