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

feat: /announcements endpoint and other additions #102

Merged
merged 24 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1cfc418
ci(qodana): correct misspelling name (#74)
validcube Sep 26, 2023
80b858c
build: slim down the docker container (#60)
VitalyArt Sep 26, 2023
77ca606
chore(deps): bump
alexandreteles Sep 26, 2023
3377fd1
chore(deps): bump JetBrains/qodana-action from 2023.2.1 to 2023.2.6 (…
dependabot[bot] Sep 27, 2023
aa657cc
chore(deps): bump actions/checkout from 3 to 4 (#78)
dependabot[bot] Sep 27, 2023
081c0d3
[pre-commit.ci] pre-commit autoupdate (#83)
pre-commit-ci[bot] Sep 27, 2023
525cebe
chore(deps): bump docker/setup-buildx-action from 2 to 3 (#86)
dependabot[bot] Sep 27, 2023
b60c609
chore(deps): bump docker/login-action from 2 to 3 (#85)
dependabot[bot] Sep 27, 2023
6536b12
chore(deps): bump docker/setup-qemu-action from 2 to 3 (#84)
dependabot[bot] Sep 27, 2023
a2ca4a4
chore(deps): bump docker/build-push-action from 4 to 5 (#88)
dependabot[bot] Sep 28, 2023
e420d26
chore(deps): bump docker/metadata-action from 4 to 5 (#89)
dependabot[bot] Sep 28, 2023
22e9cca
chore(deps): bump pydantic from 1.10.12 to 1.10.13 (#90)
dependabot[bot] Oct 2, 2023
24c8f60
feat: Add `preferred` field to socials (#100)
oSumAtrIX Oct 10, 2023
456d35b
chore(deps): bump coverage from 7.3.1 to 7.3.2 (#94)
dependabot[bot] Oct 10, 2023
8e0cb3e
chore(deps): bump JetBrains/qodana-action from 2023.2.6 to 2023.2.8 (…
dependabot[bot] Oct 10, 2023
a43c9b3
[pre-commit.ci] pre-commit autoupdate (#99)
pre-commit-ci[bot] Oct 10, 2023
e1b0521
chore(deps): bump mypy from 1.5.1 to 1.6.0 (#101)
dependabot[bot] Oct 11, 2023
b979021
chore(deps): bump asyncstdlib from 3.10.8 to 3.10.9 (#97)
dependabot[bot] Oct 11, 2023
c65b43a
chore(deps): bump aiohttp from 3.8.5 to 3.8.6 (#98)
dependabot[bot] Oct 11, 2023
8583e2a
feat: Add announcements endpoints (#91)
oSumAtrIX Oct 11, 2023
c1d7412
chore(deps): bump actions/checkout from 3 to 4 (#103)
dependabot[bot] Oct 14, 2023
bace37d
chore(deps): bump sqlalchemy from 2.0.21 to 2.0.22 (#105)
dependabot[bot] Oct 14, 2023
edcad62
feat: added branding (#104)
BenjaminHalko Oct 14, 2023
4cb51c1
chore(deps): bump mypy from 1.6.0 to 1.6.1 (#107)
dependabot[bot] Oct 19, 2023
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
.devcontainer
.git
.gitignore
.github
.vscode
54 changes: 54 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "CodeQL"

on:
push:
branches: [dev]
pull_request:
types: [opened, reopened, edited, synchronize]
schedule:
- cron: "29 5 * * 5"
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["python"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.6"

- name: Install project dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ];
then pip install -r requirements.txt;
fi

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
12 changes: 6 additions & 6 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
name: Security check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Security Checks (PyCharm Security)
uses: tonybaloney/pycharm-security@master
with:
Expand All @@ -33,24 +33,24 @@ jobs:
steps:
- name: Checkout Dockerfile
id: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
Expand All @@ -59,7 +59,7 @@ jobs:

- name: Build Docker image
id: build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ jobs:
steps:
- name: Checkout Dockerfile
id: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
id: ghcr
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
Expand All @@ -54,7 +54,7 @@ jobs:

- name: Build and push main Docker image
id: build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
build-args: GH_TOKEN=${{ secrets.GH_TOKEN }}
context: .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
python-version: "3.11.6"

- name: Install project dependencies
run: |
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/quodana.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

# custom
env.sh
persistance/database.db
10 changes: 2 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -12,15 +12,9 @@ repos:
- id: check-toml
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
rev: v0.1.0
hooks:
- id: dockerfilelint
stages: [commit]

ci:
autoupdate_branch: "dev"
36 changes: 29 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
FROM python:3.11-slim
## Build dependencies
FROM python:3.11-slim as dependencies

WORKDIR /usr/src/app

RUN apt-get update && \
apt-get install -y --no-install-recommends gcc git \
&& rm -rf /var/lib/apt/lists/*

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .

ARG GITHUB_TOKEN
ENV GITHUB_TOKEN $GITHUB_TOKEN
RUN pip install -r requirements.txt

## Image
FROM python:3.11-slim

WORKDIR /usr/src/app

RUN apt-get update && \
apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*

ENV PATH="/opt/venv/bin:$PATH"

COPY --from=dependencies /opt/venv /opt/venv
COPY . .

RUN apt update && \
apt-get install build-essential libffi-dev libssl-dev openssl --no-install-recommends -y \
&& pip install --no-cache-dir -r requirements.txt
VOLUME persistance

CMD docker/run-backend.sh
HEALTHCHECK CMD docker/run-healthcheck.sh

CMD [ "python3", "-m" , "sanic", "app:app", "--fast", "--access-logs", "--motd", "--noisy-exceptions", "-H", "0.0.0.0"]
EXPOSE 8000
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![License: AGPLv3](https://img.shields.io/github/license/revanced/revanced-api)
[![codecov](https://codecov.io/gh/ReVanced/revanced-api/branch/dev/graph/badge.svg?token=10H8D2CRQO)](https://codecov.io/gh/ReVanced/revanced-api)
[![Build and Publish Docker Image](https://github.com/revanced/revanced-api/actions/workflows/main.yml/badge.svg)](https://github.com/revanced/revanced-api/actions/workflows/main.yml)
[![Qodana | Code Quality Scan](https://github.com/revanced/revanced-api/actions/workflows/quodana.yml/badge.svg)](https://github.com/revanced/revanced-api/actions/workflows/quodana.yml)
[![Qodana | Code Quality Scan](https://github.com/revanced/revanced-api/actions/workflows/qodana.yml/badge.svg)](https://github.com/revanced/revanced-api/actions/workflows/qodana.yml)
[![PyTest | Testing and Code Coverage](https://github.com/revanced/revanced-api/actions/workflows/pytest.yml/badge.svg)](https://github.com/revanced/revanced-api/actions/workflows/pytest.yml)

---
Expand All @@ -20,7 +20,11 @@ To run this API, you need Python 3.11.x. You can install the dependencies with p
poetry install
```

Create an environment variable called `GITHUB_TOKEN` with a valid GitHub token with read access to public repositories.
Create the following environment variables:

- `GITHUB_TOKEN` with a valid GitHub token with read access to public repositories
- `SECRET_KEY` to salt login sessions
- `USERNAME` & `PASSWORD` to initialize the database with a user to login with to authenticated endpoints

Then, you can run the API in development mode with:

Expand Down
6 changes: 5 additions & 1 deletion api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
from api.info import info
from api.compat import github as compat
from api.donations import donations
from api.announcements import announcements
from api.login import login

api = Blueprint.group(ping, github, info, socials, donations, compat, url_prefix="/")
api = Blueprint.group(
login, ping, github, info, socials, donations, announcements, compat, url_prefix="/"
)
Loading