Skip to content

Commit

Permalink
feat: initial version of this Discord <-> IRC bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain committed Aug 8, 2022
1 parent 567b80f commit b72c5b2
Show file tree
Hide file tree
Showing 17 changed files with 900 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
/.env
/.git/**
9 changes: 9 additions & 0 deletions .dorpsgek.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
notifications:
global:
irc:
- openttd
- openttd.notice

pull-request:
issue:
tag-created:
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 120
inline-quotes = double

# We use 'black' for coding style; these next two warnings are not PEP-8
# compliant.
# E231 is a bug in 'black', see https://github.com/psf/black/issues/1202
ignore = E203, E231, W503
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
rebase-strategy: "disabled"
open-pull-requests-limit: 10
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- main
release:
types:
- published

jobs:
publish_image:
name: Publish image
uses: OpenTTD/actions/.github/workflows/publish-image.yml@v3

# Currently this project is not deployed yet.
# deploy:
# name: Deploy
# needs:
# - publish_image

# uses: OpenTTD/actions/.github/workflows/aws-deployment.yml@v3
# with:
# is_staging: ${{ github.ref == 'refs/heads/main' }}
# name: Dibridge
# url_production: https://weblogs.openttd.org
# url_staging: https://weblogs-staging.openttd.org
# digest: ${{ needs.publish_image.outputs.digest }}
# version: ${{ needs.publish_image.outputs.version }}
# secrets:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_REGION: ${{ secrets.AWS_REGION }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
94 changes: 94 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Testing

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

jobs:
codeql:
name: Security and Quality
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
queries: security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

docker:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
cache-from: type=gha
cache-to: type=gha,mode=max

flake8:
name: Flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Flake8
uses: TrueBrain/actions-flake8@v2
with:
path: dibridge

black:
name: Black
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Set up packages
run: |
python -m pip install --upgrade pip
pip install black
- name: Black
run: |
black -l 120 --check dibridge
check_annotations:
name: Check Annotations
needs:
- docker
- flake8
- black
# not codeql, as that reports its own status

if: always() && github.event_name == 'pull_request'

runs-on: ubuntu-latest

steps:
- name: Check annotations
uses: OpenTTD/actions/annotation-check@v2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
*.pyc
/.env
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.10-slim

ARG BUILD_VERSION="dev"

# In order to install a non-release dependency, we need git.
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /code

COPY requirements.txt \
LICENSE \
README.md \
/code/
# Needed for Sentry to know what version we are running
RUN echo "${BUILD_VERSION}" > /code/.version

RUN pip --no-cache-dir install -U pip \
&& pip --no-cache-dir install -r requirements.txt

# Validate that what was installed was what was expected
RUN pip freeze 2>/dev/null > requirements.installed \
&& diff -u --strip-trailing-cr requirements.txt requirements.installed 1>&2 \
|| ( echo "!! ERROR !! requirements.txt defined different packages or versions for installation" \
&& exit 1 ) 1>&2

COPY dibridge /code/dibridge

ENTRYPOINT ["python", "-m", "dibridge"]
CMD []
Loading

0 comments on commit b72c5b2

Please sign in to comment.