Skip to content

Commit

Permalink
Merge pull request #67 from Xithrius/sqlalchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
Xithrius authored Oct 11, 2023
2 parents 57301f2 + 72a89d6 commit b082b28
Show file tree
Hide file tree
Showing 88 changed files with 2,406 additions and 1,252 deletions.
82 changes: 41 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches:
- main
- main
pull_request:

concurrency:
Expand All @@ -19,51 +19,51 @@ jobs:
directory: ['api', 'xythrion']

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

- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "${{ matrix.directory }}/pyproject.toml"
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "${{ matrix.directory }}/pyproject.toml"

- name: Set up PDM
uses: pdm-project/setup-pdm@v2
with:
python-version: "3.11"
- name: Set up PDM
uses: pdm-project/setup-pdm@v2
with:
python-version: "3.11"

- name: Install dependencies
working-directory: ${{ matrix.directory }}
run: pdm sync
- name: Install dependencies
working-directory: ${{ matrix.directory }}
run: pdm sync

- name: Run lints
working-directory: ${{ matrix.directory }}
run: pdm lint
- name: Run lints
working-directory: ${{ matrix.directory }}
run: pdm lint

- name: Run tests
working-directory: ${{ matrix.directory }}
- name: Run tests
working-directory: ${{ matrix.directory }}
# Matplotlib tests are currently broken, skipping for now.
run: |
if [ "${{ matrix.directory }}" != 'api' ]; then
pdm test
else
echo "Skipping tests for 'api' directory."
fi
run: |
if [ "${{ matrix.directory }}" != 'api' ]; then
pdm test
else
echo "Skipping tests for 'api' directory."
fi
- name: Prepare Pull Request Payload artifact
working-directory: ${{ matrix.directory }}
id: prepare-artifact
if: always() && github.event_name == 'pull_request'
continue-on-error: true
run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json
- name: Prepare Pull Request Payload artifact
working-directory: ${{ matrix.directory }}
id: prepare-artifact
if: always() && github.event_name == 'pull_request'
continue-on-error: true
run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json

- name: Upload a Build Artifact
if: always() && steps.prepare-artifact.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v3
with:
working-directory: ${{ matrix.directory }}
name: pull-request-payload
path: pull_request_payload.json
- name: Upload a Build Artifact
if: always() && steps.prepare-artifact.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v3
with:
working-directory: ${{ matrix.directory }}
name: pull-request-payload
path: pull_request_payload.json
70 changes: 35 additions & 35 deletions .github/workflows/status_embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Status Embed
on:
workflow_run:
workflows:
- CI
- CI
types:
- completed
- completed

jobs:
status_embed:
Expand All @@ -28,45 +28,45 @@ jobs:
# A workflow_run event does not contain all the information
# we need for a PR embed. That's why we upload an artifact
# with that information in the Lint workflow.
- name: Get Pull Request Information
id: pr_info
if: github.event.workflow_run.event == 'pull_request'
run: |
curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json
DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url')
[ -z "$DOWNLOAD_URL" ] && exit 1
wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2
unzip -p pull_request_payload.zip > pull_request_payload.json
[ -s pull_request_payload.json ] || exit 3
echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)"
echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)"
echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)"
echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Pull Request Information
id: pr_info
if: github.event.workflow_run.event == 'pull_request'
run: |
curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json
DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url')
[ -z "$DOWNLOAD_URL" ] && exit 1
wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2
unzip -p pull_request_payload.zip > pull_request_payload.json
[ -s pull_request_payload.json ] || exit 3
echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)"
echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)"
echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)"
echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Send an informational status embed to Discord instead of the
# standard embeds that Discord sends. This embed will contain
# more information and we can fine tune when we actually want
# to send an embed.
- name: GitHub Actions Status Embed for Discord
uses: SebastiaanZ/github-status-embed-for-discord@main
with:
- name: GitHub Actions Status Embed for Discord
uses: SebastiaanZ/github-status-embed-for-discord@main
with:
# Our GitHub Actions webhook
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}

# Workflow information
workflow_name: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
run_number: ${{ github.event.workflow_run.run_number }}
status: ${{ github.event.workflow_run.conclusion }}
actor: ${{ github.actor }}
repository: ${{ github.repository }}
ref: ${{ github.ref }}
sha: ${{ github.event.workflow_run.head_sha }}
workflow_name: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
run_number: ${{ github.event.workflow_run.run_number }}
status: ${{ github.event.workflow_run.conclusion }}
actor: ${{ github.actor }}
repository: ${{ github.repository }}
ref: ${{ github.ref }}
sha: ${{ github.event.workflow_run.head_sha }}

pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
pr_number: ${{ steps.pr_info.outputs.pr_number }}
pr_title: ${{ steps.pr_info.outputs.pr_title }}
pr_source: ${{ steps.pr_info.outputs.pr_source }}
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
pr_number: ${{ steps.pr_info.outputs.pr_number }}
pr_title: ${{ steps.pr_info.outputs.pr_title }}
pr_source: ${{ steps.pr_info.outputs.pr_source }}
60 changes: 41 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: ruff

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-ast
- id: trailing-whitespace
- id: check-toml
- id: end-of-file-fixer

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.1.0
hooks:
- id: pretty-format-yaml
args:
- --autofix
- --preserve-quotes
- --indent=2
3 changes: 2 additions & 1 deletion api/alembic.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[alembic]
script_location = alembic
script_location = migrations
prepend_sys_path = .
output_encoding = utf-8
version_path_separator = os

[post_write_hooks]
Expand Down
35 changes: 0 additions & 35 deletions api/alembic/versions/19ac78d5b70e_created_trusted_table.py

This file was deleted.

38 changes: 0 additions & 38 deletions api/alembic/versions/55d7c78f3b9c_created_web_map_table.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit b082b28

Please sign in to comment.