Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .devcontainer/Dockerfile

This file was deleted.

58 changes: 0 additions & 58 deletions .devcontainer/devcontainer.json

This file was deleted.

41 changes: 0 additions & 41 deletions .devcontainer/docker-compose.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
node_modules/
.github/
.mypy_cache/
.pytest_cache/
__pycache__/
*.pyc
.venv/
.scannerwork/
.ruff_cache/
33 changes: 33 additions & 0 deletions .github/workflows/format-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Format App

on:
push:
branches: [master, develop]

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install ruff
run: pip install ruff

- name: Run ruff format
run: ruff format packet

- name: Commit and push changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --cached --quiet || git commit -m "Auto-format code with ruff"
git push
12 changes: 6 additions & 6 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pylint
python -m pip install uv
if [ -f requirements.txt ]; then uv pip install -r requirements.txt --system; fi
- name: Lint with ruff
run: |
pylint packet/routes packet
ruff check packet
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the ruff FAQ, seems like they're more confident in how well it can replace pylint than a few years ago, but it also discuss that they can be complimentary. Would it make sense to use ruff locally for anyone using it for commit hooks, and pylint in CI for completeness

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't hurt, I just wanted to avoid any complications 2 linting systems could possibly bring.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they can be tuned to work pretty well together, the pylint project uses both


typecheck:
runs-on: ubuntu-latest
Expand All @@ -50,8 +50,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install uv
if [ -f requirements.txt ]; then uv pip install -r requirements.txt --system; fi
- name: Typecheck with mypy
run: |
# Disabled error codes to discard errors from imports
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ ENV/

# vscode
.vscode
.devcontainer

# SonarQube
.scannerwork

# Configurations
config.py
Expand Down Expand Up @@ -132,4 +136,4 @@ packet/static/site.webmanifest
faviconData.json

# csvs
*.csv
*.csv
98 changes: 0 additions & 98 deletions .pylintrc

This file was deleted.

7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN mkdir /opt/packet
WORKDIR /opt/packet

COPY requirements.txt /opt/packet/
RUN pip install -r requirements.txt
RUN pip install uv && uv pip install -r requirements.txt --system

COPY package.json /opt/packet/
COPY yarn.lock /opt/packet/
Expand All @@ -32,4 +32,9 @@ RUN gulp production && \
# Set version for apm
RUN echo "export DD_VERSION=\"$(python3 packet/git.py)\"" >> /tmp/version

RUN groupadd -r packet && useradd --no-log-init -r -g packet packet && \
chown -R packet:packet /opt/packet

USER packet

CMD ["/bin/bash", "-c", "source /tmp/version && ddtrace-run gunicorn packet:app --bind=0.0.0.0:8080 --access-logfile=- --timeout=600"]
9 changes: 7 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/python:3.9-slim-trixie
FROM ghcr.io/astral-sh/uv:python3.9-bookworm-slim

RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
RUN apt-get -yq update && \
Expand All @@ -14,7 +14,7 @@ RUN mkdir /opt/packet
WORKDIR /opt/packet

COPY requirements.txt /opt/packet/
RUN pip install -r requirements.txt
RUN uv pip install -r requirements.txt --system

COPY package.json /opt/packet/
COPY yarn.lock /opt/packet/
Expand All @@ -29,6 +29,11 @@ RUN gulp production && \
apt-get -yq autoremove && \
apt-get -yq clean all

RUN groupadd -r packet && useradd --no-log-init -r -g packet packet && \
chown -R packet:packet /opt/packet

USER packet

EXPOSE 8000

CMD ["/bin/bash", "-c", "python3 wsgi.py"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ All DB commands are from the `Flask-Migrate` library and are used to configure D
docs [here](https://flask-migrate.readthedocs.io/en/latest/) for details.

## Code standards
This project is configured to use Pylint and mypy. Commits will be pylinted and typechecked by GitHub actions and if the
This project is configured to use ruff and mypy. Commits will be ruffed and typechecked by GitHub actions and if the
score drops your build will fail blocking you from merging. To make your life easier just run it before making a PR.

To run pylint and mypy use these commands:
To run ruff and mypy use these commands:
```bash
pylint packet/routes packet
ruff check packet
mypy --disable-error-code import --disable-error-code name-defined --disallow-untyped-defs --exclude routes packet
```

Expand Down
1 change: 1 addition & 0 deletions config.env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Default configuration settings and environment variable based configuration logic
See the readme for more information
"""

from distutils.util import strtobool
from os import environ, path, getcwd

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ requireDir('./tasks', {recurse: true});
// Default task
gulp.task('default', gulp.parallel('css', 'js'));
gulp.task('production', gulp.parallel('css', 'js', 'generate-favicon'));
gulp.task('lint', gulp.parallel('pylint'));
gulp.task('lint', gulp.parallel('ruff'));
6 changes: 3 additions & 3 deletions gulpfile.js/tasks/pylint.js → gulpfile.js/tasks/ruff.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const gulp = require('gulp');
const exec = require('child_process').exec;

let pylintTask = (cb) => {
exec('pylint --load-plugins pylint_quotes packet/routes packet', function (err, stdout, stderr) {
let ruffTask = (cb) => {
exec('ruff check packet', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
};

gulp.task('pylint', pylintTask);
gulp.task('ruff', ruffTask);
Loading