Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging! #434

Merged
merged 8 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ omit =
blossom/middleware.py,
blossom/instrumentation.py,
blossom/settings/*,
bootstrap/*,
blossom/bootstrap/*,
blossom/social_auth/*,
blossom/conftest.py,
blossom/docs/*
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import-order-style = pycharm
max-complexity = 10
max-line-length = 90
use-varnames-strict-mode = true
exclude = .git,__pycache__,build,dist,.venv,bootstrap/*,*/migrations/,docker/*
exclude = .git,__pycache__,build,dist,.venv,blossom/bootstrap/*,*/migrations/*,docker/*
per-file-ignores =
blossom/settings/routing.py:F401,F403
42 changes: 42 additions & 0 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10.x'
- uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
- name: Install Dependencies
run: |
pip install --upgrade pip
sudo apt-get install libjpeg8 libjpeg-dev libpng-dev libpq-dev -y
poetry install
- name: Add CURRENT_TIME env property
# the smart thing to do here would be to use the commit hash, but
# github releases are ALPHABETIZED, so a commit hash of `abcdef` will
# not be listed as the latest release if `defabc` came before. (╥﹏╥)
run: echo "CURRENT_TIME_VERSION=v$(date '+%s')" >> $GITHUB_ENV
- name: Build the sucker
run: |
sed -i -e "s/?????/${{ env.CURRENT_TIME_VERSION }}/g" blossom/__init__.py
make build
- uses: ncipollo/release-action@v1
with:
artifacts: "build/blossom.pyz"
body: "It's releasin' time"
generateReleaseNotes: true
tag: ${{ env.CURRENT_TIME_VERSION }}
commit: master
token: ${{ secrets.GITHUB_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/bump-version.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build blossom.pyz and test

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10.x'
- uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
- name: Install Dependencies
run: |
pip install --upgrade pip
sudo apt-get install libjpeg8 libjpeg-dev libpng-dev libpq-dev -y
poetry install
- name: Add CURRENT_TIME env property
# the smart thing to do here would be to use the commit hash, but
# github releases are ALPHABETIZED, so a commit hash of `abcdef` will
# not be listed as the latest release if `defabc` came before. (╥﹏╥)
run: echo "CURRENT_TIME_VERSION=v$(date '+%s')" >> $GITHUB_ENV
- name: Build the sucker
run: |
sed -i -e "s/?????/${{ env.CURRENT_TIME_VERSION }}/g" blossom/__init__.py
make build
- name: Remove source to make sure it doesn't interfere with the tests
run: rm -rf blossom/
- name: Run selfcheck on compiled binary
run: ./build/blossom.pyz selfcheck
14 changes: 5 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ on: [pull_request]

jobs:
build:
runs-on: ubuntu-18.04
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
runs-on: ubuntu-latest

steps:
- name: Checkout current branch
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1.1.1
python-version: '3.10.x'
- uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
- name: Install Dependencies
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ venv.bak/

static/
.idea/*

# packaging artifacts
setup.py
blossom.pyz
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
line_length = 88
multi_line_output = 3
include_trailing_comma = True
known_third_party = beeline,better_exceptions,blossom_wrapper,decorator_include,django,django_filters,dotenv,dpath,drf_yasg,ipware,markdown,mimesis,praw,prawcore,psaw,pytest,pytest_django,pytz,requests,rest_framework,rest_framework_api_key,revproxy,slack,social_core,social_django,stripe,toml
known_third_party = beeline,better_exceptions,blossom_wrapper,click,decorator_include,django,django_filters,dotenv,dpath,drf_yasg,gunicorn,ipware,markdown,mimesis,praw,prawcore,psaw,pytest,pytest_django,pytz,requests,rest_framework,rest_framework_api_key,revproxy,shiv,slack,social_core,social_django,stripe,toml
skip=venv,.venv,env,migrations
3 changes: 0 additions & 3 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
# Unless a later match takes precedence, @global-owner1 and @global-owner2
# will be requested for review when someone opens a pull request.
* @GrafeasGroup/core

*.sh @thelonelyghost
test/* @thelonelyghost
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft blossom
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
setup:
poetry run python manage.py collectstatic --noinput --settings=blossom.settings.testing > /dev/null
poetry run poetry2setup > setup.py

build: setup shiv

clean:
rm setup.py

shiv:
mkdir -p build
poetry run shiv -c blossom -o build/blossom.pyz . --compressed
6 changes: 0 additions & 6 deletions app/apps.py

This file was deleted.

1 change: 0 additions & 1 deletion app/tests.py

This file was deleted.

52 changes: 0 additions & 52 deletions authentication/migrations/0001_initial.py

This file was deleted.

14 changes: 1 addition & 13 deletions blossom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
"""Metadata about Blossom. Nothing to see here."""

import os

import toml

try:
with open(
os.path.join(os.path.dirname(__file__), "..", "pyproject.toml"), "r"
) as f:
__version__ = toml.load(f)["tool"]["poetry"]["version"]
except OSError:
__version__ = "unknown"
pass
__version__ = "?????" # will be replaced by CI pipeline
File renamed without changes.
2 changes: 1 addition & 1 deletion api/admin.py → blossom/api/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Configuration for the admin interface of Django."""
from django.contrib import admin

from api.models import Submission, Transcription
from blossom.api.models import Submission, Transcription


class SubmissionAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion api/apps.py → blossom/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class ApiConfig(AppConfig):
name = "api"
name = "blossom.api"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 2.2.12 on 2020-05-06 02:50

import api.models
from django.db import migrations, models
import django.utils.timezone
from django.db import migrations, models

import blossom.api.models


class Migration(migrations.Migration):
Expand Down Expand Up @@ -35,7 +36,9 @@ class Migration(migrations.Migration):
),
(
"original_id",
models.CharField(default=api.models.create_id, max_length=36),
models.CharField(
default=blossom.api.models.create_id, max_length=36
),
),
(
"create_time",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generated by Django 2.2.12 on 2020-05-06 02:50

import api.models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

import blossom.api.models


class Migration(migrations.Migration):
Expand All @@ -27,7 +28,7 @@ class Migration(migrations.Migration):
model_name="transcription",
name="source",
field=models.ForeignKey(
default=api.models.get_default_source,
default=blossom.api.models.get_default_source,
on_delete=django.db.models.deletion.CASCADE,
related_name="api_transcription_related",
to="api.Source",
Expand Down Expand Up @@ -66,7 +67,7 @@ class Migration(migrations.Migration):
model_name="submission",
name="source",
field=models.ForeignKey(
default=api.models.get_default_source,
default=blossom.api.models.get_default_source,
on_delete=django.db.models.deletion.CASCADE,
related_name="api_submission_related",
to="api.Source",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 2.2.12 on 2020-05-06 17:21

import api.models
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models

import blossom.api.models


class Migration(migrations.Migration):
Expand All @@ -16,7 +17,7 @@ class Migration(migrations.Migration):
model_name="submission",
name="source",
field=models.ForeignKey(
default=api.models.get_default_source,
default=blossom.api.models.get_default_source,
on_delete=django.db.models.deletion.CASCADE,
to="api.Source",
),
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions api/models.py → blossom/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from django.db import models
from django.utils import timezone

from api.slack import client
from ocr.errors import OCRError
from ocr.helpers import escape_reddit_links, process_image, replace_shortlinks
from blossom.api.slack import client
from blossom.ocr.errors import OCRError
from blossom.ocr.helpers import escape_reddit_links, process_image, replace_shortlinks


def create_id() -> uuid.UUID: # pragma: no cover
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions api/serializers.py → blossom/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from django.contrib.auth.models import User
from rest_framework import serializers

from api.models import Source, Submission, Transcription
from authentication.models import BlossomUser
from blossom.api.models import Source, Submission, Transcription
from blossom.authentication.models import BlossomUser


class UserSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
File renamed without changes.
Loading