Skip to content

Commit

Permalink
Merge pull request #823 from CodeForAfrica/chore/upgrade_pants_2.23
Browse files Browse the repository at this point in the history
Upgrade `pants` to latest version
  • Loading branch information
kilemensi authored Nov 22, 2024
2 parents 4b262cb + c946719 commit d33e8de
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 20 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://editorconfig.org/

root = true

[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

# Docstrings and comments use max_line_length = 79
[*.py]
profile = black

# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203,E701
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# yamllint disable rule:line-length
name: TwoopsTracker | Continuous Deployment
on:
"on":
push:
branches:
- main
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# yamllint disable rule:line-length
name: TwoopsTracker | Continuous Integration
on:
"on":
pull_request:
types: [opened, synchronize, reopened]

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
# yamllint disable-line rule:line-length
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

Expand Down
9 changes: 9 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default

rules:
# https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.line_length
line-length:
max: 88 # profile=black
# https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.document_start
document-start:
present: false
7 changes: 5 additions & 2 deletions 3rdparty/py/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
boto3==1.35.64
celery==5.4.0
dj-rest-auth[with_social]==5.1.0
dj-rest-auth==5.1.0
# Match dj-rest-auth[with_social]==5.1.0
django-allauth>=0.56.0,<0.62.0
Django==3.2.23
django-cors-headers==4.5.0
django-storages==1.14.4
djangorestframework==3.15.1
djangorestframework-simplejwt==5.3.1
environs[django]==11.2.0
environs[django]==10.3.0
google-api-python-client==2.153.0
google-auth==2.36.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.1
greenlet==3.1.1
Expand Down
1 change: 0 additions & 1 deletion 3rdparty/py/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-r requirements-all.txt

black==24.10.0
psycopg2-binary==2.9.10
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@

| Name | Description |
| ----------------------------------------------- | -------------------------------------------- |
| [**PesaCheck Meedan Bridge**](./pesacheck_meedan_bridge/README.md) | A simple service to move articles between the two platforms |
| [**TwoopsTracker**](./twoops_tracker/README.md) | A Twitter-based disinformation tracking tool |

## Packages

| Name | Description |
| ---------------------------------- | -------------------------------------------------------------- |
| [**`dj-cmd`**](./dj-cmd/README.md) | Command-line utility for running Django when bundled in `pex`. |

## Development

This [`monorepo`](https://monorepo.tools/) uses [`Pantsbuild`](https://www.pantsbuild.org/) build system. To get started, please ensure you have [`Pants`](https://www.pantsbuild.org/stable/docs/getting-started/installing-pants) installed on your machine.

### Pants Plugins

| Name | Description |
| ----------------------------------------------- | -------------------------------------------- |
| **VersionSetup** | |
1 change: 0 additions & 1 deletion docker-compose.yml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
services:
db:
image: postgres:13.4
Expand Down
27 changes: 22 additions & 5 deletions pants.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[GLOBAL]
pants_version = "2.19.0"
pants_version = "2.23.0"
pythonpath = ["%(buildroot)s/pants-plugins"]

backend_packages.add = [
"pants.backend.build_files.fmt.black",
"pants.backend.build_files.fmt.ruff",
"pants.backend.docker",
"pants.backend.docker.lint.hadolint",
"pants.backend.plugin_development",
"pants.backend.python",
"pants.backend.python.lint.black",
"pants.backend.python.mixed_interpreter_constraints",
"pants.backend.python.lint.bandit",
"pants.backend.python.lint.docformatter",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.isort",
Expand All @@ -21,6 +22,8 @@ backend_packages.add = [
# Expiremental backends
"pants.backend.experimental.python",
"pants.backend.experimental.python.framework.django",
"pants.backend.experimental.python.lint.ruff.check",
"pants.backend.experimental.python.lint.ruff.format",
"pants.backend.experimental.tools.yamllint",
# In-repo plugins
"internal_plugins.versioned_setup",
Expand All @@ -40,10 +43,24 @@ root_patterns = [
]

[python]
enable_resolves = false
interpreter_constraints = ["==3.11.*"]

[black]
args = ["--preview"]
[python-repos]
find_links = ["https://wheels.pantsbuild.org/simple"]

[generate-lockfiles]
diff = true

[bandit]
args = ["--quiet"]

[mypy]
requirements = ["django-stubs"]
interpreter_constraints = ["==3.11.*"]

[pyupgrade]
args = ["--py36-plus"]

[docker]
build_args = ["VERSION"]
Expand Down
3 changes: 3 additions & 0 deletions pesacheck_meedan_bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PesaCheck Meedan Bridge

A simple service to pull articles from PesaCheck and post them to Meedan Check
2 changes: 1 addition & 1 deletion pesacheck_meedan_bridge/py/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import sys

import lxml.html
import lxml.html # nosec B410
import requests
import sentry_sdk
import settings
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[project]
requires-python = ">= 3.11"

[tool.isort]
profile = "black"

[tool.mypy]
ignore_missing_imports = true
# TODO(kilemensi): mypy django stubs

[tool.ruff]
target-version = "py311" # default: py39

[tool.setuptools_scm]
write_to = "VERSION"
16 changes: 8 additions & 8 deletions twoops_tracker/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## TwoopsTracker
# TwoopsTracker

A Twitter-based disinformation tracking tool built on a web-based dashboard that collects deleted tweet content from previously identified trolls and disinformation actors. The project seeks to help monitor the social posts of known disinfo actors. The primary tangible output of the project is to expose trolls behind toxic disinformation campaigns who routinely cover their tracks by deleting original inflammatory social media posts that sparked hate speech, disinformation campaigns or conspiracy theories.

Expand All @@ -14,30 +14,30 @@ and modify the `.env` file according to your needs.

## Build

To build a pex binary, run:
To build a `pex` binary, run:

```sh
./pants package twoops_tracker/py:twoopstracker
pants package twoops_tracker/py:twoopstracker
```

To build the docker image, run:

```sh
VERSION=$(cat twoops_tracker/py/VERSION) ./pants package twoops_tracker/docker:twoopstracker
VERSION=$(cat twoops_tracker/py/VERSION) pants package twoops_tracker/docker:twoopstracker
```

## Run

To run pex binary, execute:
To run `pex` binary, execute:

```sh
./pants run twoops_tracker/py:twoopstracker
pants run twoops_tracker/py:twoopstracker
```

To run the built docker image, execute:

```sh
docker-compose --env-file ./twoops_tracker/.env up twoopstracker
docker compose --env-file ./twoops_tracker/.env up twoopstracker
```

**NOTE**: You may need to run `postres` container first to make sure database
Expand All @@ -46,5 +46,5 @@ is ready to receive connections _before_ starting the `twoopstracker` app.
To do so, run:

```sh
docker-compose --env-file ./twoops_tracker/.env up db
docker compose --env-file ./twoops_tracker/.env up db
```
2 changes: 2 additions & 0 deletions twoops_tracker/py/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ python_sources(
"3rdparty/py:requirements-all#django-storages",
"3rdparty/py:requirements-all#djangorestframework-simplejwt",
"3rdparty/py:requirements-all#google-api-python-client",
"3rdparty/py:requirements-all#google-auth",
"3rdparty/py:requirements-all#google-auth-httplib2",
"3rdparty/py:requirements-all#google-auth-oauthlib",
"3rdparty/py:requirements-all#dj-rest-auth",
"3rdparty/py:requirements-all#django-allauth",
"3rdparty/py:requirements-all#gunicorn",
"3rdparty/py:requirements-all#celery",
"3rdparty/py:requirements-all#redis",
Expand Down
1 change: 1 addition & 0 deletions twoops_tracker/py/twoopstracker/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""twoopstracker URL Configuration."""

from django.contrib import admin
from django.urls import include, path

Expand Down

0 comments on commit d33e8de

Please sign in to comment.