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

Contemplative Constellations #2

Open
wants to merge 203 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
dd9fe53
Initial commit
ItsDrike Jul 15, 2024
0934801
Update gitignore
ItsDrike Jul 15, 2024
ff04e8b
Enforce LF line endings
ItsDrike Jul 15, 2024
81b652d
Add editorconfig file
ItsDrike Jul 15, 2024
f2a8192
Customize the template
ItsDrike Jul 15, 2024
a1b1193
Replace template readme
ItsDrike Jul 15, 2024
38882db
Only run unit-tests workflow on 3.12
ItsDrike Jul 15, 2024
3fe1458
Run pytest directly in unit-tests workflow
ItsDrike Jul 15, 2024
96cdda1
Remove empty blank lines at the end of files
ItsDrike Jul 16, 2024
296b705
Add vscode suggested extension: ruff
ItsDrike Jul 16, 2024
ee7d4eb
Ignore no tests found pytest error
ItsDrike Jul 16, 2024
e9e2f67
Add coverage normalization script
ItsDrike Jul 16, 2024
f9ad24c
Add basedpyright (#1)
ItsDrike Jul 16, 2024
5ce74cc
Enforce multi-line docstring starting at first line
ItsDrike Jul 17, 2024
c997e65
Add py.typed
ItsDrike Jul 17, 2024
8f920be
Remove TODO on adding project authors
ItsDrike Jul 18, 2024
bedd14c
Fix typo in project authors (name)
ItsDrike Jul 18, 2024
10b45cb
Benjiguy (#2)
dragonblz Jul 18, 2024
336c4a1
add v33010 author in pyproject.toml (#4)
V33010 Jul 18, 2024
9cf1633
Add Paillat author (#3)
Paillat-dev Jul 18, 2024
a179508
Add very basic bot implementation
ItsDrike Jul 18, 2024
a7a335c
Use python-decouple to read env vars
ItsDrike Jul 18, 2024
af247a3
Add proper logging support (with colors)
ItsDrike Jul 18, 2024
34f64ae
Add support for extensions (cogs)
ItsDrike Jul 18, 2024
dcd61ac
Add setup guide to README
ItsDrike Jul 18, 2024
da740ce
Split authors list to multiple lines (shorter line length)
ItsDrike Jul 18, 2024
79bad04
Fix typo in log message
ItsDrike Jul 18, 2024
e5a6792
Fix wording in README
ItsDrike Jul 18, 2024
f91dea7
Document logging variables
ItsDrike Jul 18, 2024
575bf76
Merge pull request #5 from ItsDrike/basic-bot
ItsDrike Jul 18, 2024
349106d
Lift some typing requirements (#7)
ItsDrike Jul 19, 2024
ec44c9f
Add basic error handler (#6)
ItsDrike Jul 19, 2024
3e51b03
Add sudo / debug cog (#8)
ItsDrike Jul 19, 2024
088b9ea
:construction_worker: Add Dockerfile
Paillat-dev Jul 18, 2024
e40ddb0
:construction_worker: Add docker-compose.yaml
Paillat-dev Jul 18, 2024
2faac63
:construction_worker: Add .dockerignore
Paillat-dev Jul 18, 2024
9239e8c
:pushpin: Pin poetry version and change app directory
Paillat-dev Jul 19, 2024
bf5bb67
:construction_worker: Add docker action
Paillat-dev Jul 19, 2024
1e07c03
:page_facing_up: Keep License
Paillat-dev Jul 19, 2024
9ef424c
:see_no_evil: ignore `.git/`
Paillat-dev Jul 19, 2024
6ffb055
:construction_worker: Use Cosign version instead of hash
Paillat-dev Jul 19, 2024
0d26782
Merge pull request #9 from ItsDrike/add-docker
ItsDrike Jul 19, 2024
ce2e779
:rocket: Add ci-cd automatic deployment
Paillat-dev Jul 19, 2024
f1417ea
:rocket: Add ci-cd automatic deployment
Paillat-dev Jul 19, 2024
7d4a3dc
Merge pull request #11 from ItsDrike/cd-deployment
Paillat-dev Jul 19, 2024
d7866ac
start help cog (#10)
dragonblz Jul 19, 2024
38ca2ad
:green_heart: Improve CD by also deploying on workflow dispatch
Paillat-dev Jul 19, 2024
a070ab5
Fix aiohttp client not getting properly closed
ItsDrike Jul 19, 2024
6bf439c
Fix wording in docstrings within the help cog
ItsDrike Jul 19, 2024
59a3134
Merge pull request #13 from ItsDrike/cd-deployment
Paillat-dev Jul 19, 2024
2a14010
:green_heart: Use POST request to deploy on portainer
Paillat-dev Jul 19, 2024
545f094
Merge pull request #14 from ItsDrike/improve-help
ItsDrike Jul 19, 2024
e3c3032
Merge pull request #15 from ItsDrike/cd-deployment
Paillat-dev Jul 19, 2024
3675899
improve help command (#16)
dragonblz Jul 19, 2024
a259b3a
Add ash8121 to authors
fieryash Jul 20, 2024
a66c058
Merge pull request #17 from ItsDrike/add-ash8121-to-authors
Paillat-dev Jul 20, 2024
8fd4d38
Clean up some code
ItsDrike Jul 20, 2024
23d79a0
Rename mention_command.py to markdown.py
ItsDrike Jul 20, 2024
31ea0a4
Remove unused bot parameter from mention_command func
ItsDrike Jul 20, 2024
f94ddb0
Isolate fail & success emojis to project constants
ItsDrike Jul 20, 2024
b80667e
Merge pull request #18 from ItsDrike/clean-up-some-code
ItsDrike Jul 20, 2024
c9222e9
Help command (#23)
dragonblz Jul 20, 2024
b0b42e8
Use a custom bot subclass to hold state (#28)
ItsDrike Jul 21, 2024
961c241
:construction_worker: Build docker arm64 as well
Paillat-dev Jul 21, 2024
c0923e6
ruff: Ignore pandas-vet (PD)
ItsDrike Jul 21, 2024
3bd70cd
💡 Add explanatory comment
Paillat-dev Jul 21, 2024
5ba889e
Merge pull request #29 from ItsDrike/docker-multi-platform
Paillat-dev Jul 21, 2024
c2c0117
Add docker-compose that builds the image locally
ItsDrike Jul 20, 2024
d7b40fe
Add documentation on using docker
ItsDrike Jul 20, 2024
aa1c861
Add command examples on using docker-compose
ItsDrike Jul 21, 2024
3101640
Add basic structure for tvdb support
ItsDrike Jul 19, 2024
36de360
Add tvdb client
ItsDrike Jul 19, 2024
a7f2739
:heavy_plus_sign: Add pydantic
Paillat-dev Jul 20, 2024
4e29d21
:construction: Add pydantic models for /search
Paillat-dev Jul 20, 2024
dab6811
:heavy_plus_sign: Add `datamodel-code-generator` to dev dependency group
Paillat-dev Jul 20, 2024
ed2541b
:sparkles: Add base tvdb client (incomplete)
Paillat-dev Jul 20, 2024
c796a49
:sparkles: Add movie types to the tvdb client
Paillat-dev Jul 20, 2024
c7ab09c
:sparkles: Add tvdb_info extension
Paillat-dev Jul 20, 2024
5b54257
:sparkles: Add default search both to /search [type]
Paillat-dev Jul 20, 2024
d05cdf4
:wrench: Add settings related to THETVDB
Paillat-dev Jul 20, 2024
c883956
:adesive_bandage: id is not nullable. This thing made everything null…
Paillat-dev Jul 20, 2024
eca0d48
:lipstick: Improve UI
Paillat-dev Jul 20, 2024
f9b9da6
:coffin: Remove swagger.yml
Paillat-dev Jul 21, 2024
24b127a
:sparkles: Add generate-tvdb-models script
Paillat-dev Jul 21, 2024
59f19c8
:sparkles: Improve tvdb
Paillat-dev Jul 21, 2024
37ddfc4
:wastebasket: Clean up code
Paillat-dev Jul 21, 2024
79d4400
Right
Paillat-dev Jul 21, 2024
9533061
:recycle: Fix stuff
Paillat-dev Jul 21, 2024
4d6caae
Make requested changes
Paillat-dev Jul 21, 2024
1e42dc5
Merge pull request #12 from ItsDrike/add-tvdb
ItsDrike Jul 21, 2024
17f1c05
:ambulance: Oops - inverted position of decorators
Paillat-dev Jul 21, 2024
6d787c4
Fix grammar and add markdown alert blocks
ItsDrike Jul 21, 2024
40f4c0f
Merge pull request #30 from ItsDrike/hotfix-oops
Paillat-dev Jul 21, 2024
ab90638
Merge pull request #25 from ItsDrike/add-locally-built-docker-compose
ItsDrike Jul 21, 2024
ae28455
Add sqlalchemy
ItsDrike Jul 21, 2024
67d88a4
Add README to db_tables/
ItsDrike Jul 21, 2024
479fd95
Add alembic
ItsDrike Jul 21, 2024
35975b9
Add initial migration
ItsDrike Jul 21, 2024
8c97bf2
Run ruff as post-hook for alembic autogen migrations
ItsDrike Jul 21, 2024
93080a6
Add readme to alembic-migrations/
ItsDrike Jul 21, 2024
cb3d8af
Use our logging instead of default logging for alembic
ItsDrike Jul 21, 2024
7654a62
Improve env.py file for alembic
ItsDrike Jul 21, 2024
5d2f741
Automatically run alembic migrations when needed
ItsDrike Jul 21, 2024
7d89a62
Suppress alembic and aiosqlite debug logs
ItsDrike Jul 21, 2024
7493878
Explain alembic stamping
ItsDrike Jul 21, 2024
0dec86c
Improve alembic readme
ItsDrike Jul 21, 2024
ddddcb3
Add example orm database classes
ItsDrike Jul 21, 2024
f86d72b
Merge pull request #35 from ItsDrike/add-database
ItsDrike Jul 21, 2024
af3838e
Suppress some spammy py-cord logs
ItsDrike Jul 21, 2024
afb235f
Merge pull request #38 from ItsDrike/suppress-discord-debug-logs
ItsDrike Jul 21, 2024
3aeab44
:sparkles: Improve he way pydantic models are generated and a couple …
Paillat-dev Jul 21, 2024
2af0d6c
:sparkles: Improve tvdb client and example extension
Paillat-dev Jul 21, 2024
6e9058a
Update docstring of FetchMeta
Paillat-dev Jul 21, 2024
a37fbd9
Update src/tvdb/client.py
Paillat-dev Jul 21, 2024
1344223
:adhesive_bandage: Fix id format in /search
Paillat-dev Jul 21, 2024
5eda0c0
Update src/tvdb/client.py
Paillat-dev Jul 21, 2024
19834a0
:adhesive_bandage: Change the way TVDBClient.search works
Paillat-dev Jul 21, 2024
705bbb1
:adhesive_bandage: Use overloads on fetch
Paillat-dev Jul 21, 2024
60a78af
:adhesive_bandage: Make bool kwarg
Paillat-dev Jul 21, 2024
a6ab0ef
Merge pull request #40 from ItsDrike/tvdb-fixes
Paillat-dev Jul 21, 2024
32efa7c
:adhesive_bandage: Handle no results correctly
Paillat-dev Jul 21, 2024
655a6c5
Merge pull request #43 from ItsDrike/patch-1
Paillat-dev Jul 21, 2024
3780a3a
Added support for sub-groups in slash commands.
fieryash Jul 23, 2024
6a93263
Merge pull request #45 from ItsDrike/issue-19-recursive-slash-commands
ItsDrike Jul 23, 2024
998c796
:sparkles: Add imlementation placeholders
Paillat-dev Jul 23, 2024
52a5366
:adhesive_bandage: Fix tvdb iterator (#46)
Paillat-dev Jul 23, 2024
d0f53b5
Merge pull request #47 from ItsDrike/tvdb-placeholders
ItsDrike Jul 23, 2024
b92ae41
add cache with aiocached
dragonblz Jul 24, 2024
147bc78
changed copyright holders
dragonblz Jul 24, 2024
13d1ef9
changed copyright
dragonblz Jul 24, 2024
1d11baf
Merge pull request #55 from ItsDrike/copyright
ItsDrike Jul 24, 2024
27867e9
Add 1h ttl to cached items and make cache a bot attribute
Paillat-dev Jul 25, 2024
dd12691
Merge pull request #54 from ItsDrike/add-cache
ItsDrike Jul 25, 2024
043c69f
Add base implementation for rate-limiting
ItsDrike Jul 24, 2024
0f2bdc1
Use a single tvdb client across the cog
ItsDrike Jul 25, 2024
2ac8d27
Apply tvdb client wide rate-limit
ItsDrike Jul 24, 2024
3b61f4c
Add rate limit decorator function
ItsDrike Jul 25, 2024
bb3f7e7
Add prefix_key bool arg to the rate limit decorator
ItsDrike Jul 25, 2024
8e4805b
Ignore debug logs from aiocache
ItsDrike Jul 25, 2024
617e2d7
Enforce per-user rate limits on /search
ItsDrike Jul 25, 2024
425c327
Merge pull request #58 from ItsDrike/rate-limits
ItsDrike Jul 25, 2024
7843e45
:card_file_box: Add basic models
Paillat-dev Jul 24, 2024
e4ce403
Merge pull request #56 from ItsDrike/db-models
ItsDrike Jul 25, 2024
5352508
Ignore discord.webhook.async_ debug logs
ItsDrike Jul 25, 2024
b8f142c
Install operations proxy before running auto-migrations
ItsDrike Jul 25, 2024
cae4086
Merge pull request #62 from ItsDrike/fix-alembic
ItsDrike Jul 25, 2024
54e1481
Enable alembic logs for CLI (#63)
ItsDrike Jul 26, 2024
cb59f81
:sparkles: episodes and seasons support
fieryash Jul 25, 2024
e16d21f
Merge pull request #57 from ItsDrike/tvdb-episodes
ItsDrike Jul 26, 2024
e7a3bfe
:adhesive_bandage: Add `UserListItemKind`
Paillat-dev Jul 26, 2024
54122fc
Merge pull request #65 from ItsDrike/fix-not-unique-ids
ItsDrike Jul 26, 2024
f73e725
:sparkles: Add user interface for marking as fav/watched, and make th…
Paillat-dev Jul 26, 2024
bdf02d5
Handle item already existing in user list
ItsDrike Jul 27, 2024
8b38ea0
Forward the generic param for Button from ReactiveButton
ItsDrike Jul 27, 2024
68787b5
Move inline comment for ReactiveButton to docstring
ItsDrike Jul 27, 2024
02eacf9
Merge pull request #67 from ItsDrike/Many-things
ItsDrike Jul 27, 2024
0f7e9ea
Run sqlite migrations as batch
ItsDrike Jul 27, 2024
7f71ab3
(Re)create the initial migration
ItsDrike Jul 27, 2024
a5c1990
Add DB_ALWAYS_MIGRATE option for debugging migrations
ItsDrike Jul 27, 2024
482666f
Merge pull request #68 from ItsDrike/sqlite-migrations
ItsDrike Jul 27, 2024
c63350b
fixed database
dragonblz Jul 27, 2024
f03d4e4
Merge pull request #69 from ItsDrike/fix-database
ItsDrike Jul 27, 2024
2b94e13
:sparkles: Use last season episode to mark as watched / unwatched.
dragonblz Jul 27, 2024
badc1bb
Merge pull request #71 from ItsDrike/watch-logic
ItsDrike Jul 28, 2024
bbc1855
Fix overload declaration for Meida.fetch
ItsDrike Jul 27, 2024
0920b9c
Mark _ReactiveView classes as final
ItsDrike Jul 27, 2024
342f529
Basic /profile support
ItsDrike Jul 27, 2024
0501bc7
Bump pylint max-args
ItsDrike Jul 27, 2024
921ffe7
Support using episodes in list_put_item_safe
ItsDrike Jul 27, 2024
207570b
Completely rework tvdb_info ui classes
ItsDrike Jul 28, 2024
9124368
Move movie & series emoji constants to settings
ItsDrike Jul 28, 2024
e5c9132
wip - this dosent work
Paillat-dev Jul 28, 2024
853cbc2
Fix some typos
ItsDrike Jul 28, 2024
cd769f6
Fix UserListItem relationships
ItsDrike Jul 28, 2024
4d99c56
Add relationships between episode & series
ItsDrike Jul 28, 2024
3c5b728
Increase tvdb rate limit significantly (100/5s)
ItsDrike Jul 28, 2024
ecb4d1d
wip: Rework profile view
ItsDrike Jul 28, 2024
ec9de9c
Fix things
Paillat-dev Jul 28, 2024
7d9aadd
Properly handle errors in views
ItsDrike Jul 28, 2024
44a8476
fixes
Paillat-dev Jul 28, 2024
f72ce18
Tvdb says they send you 100 chars but then they send you more than that
Paillat-dev Jul 28, 2024
a740733
Don't show result picker for single result
ItsDrike Jul 28, 2024
126454c
Fix groupby dosen't work for multiple groupable blocks
Paillat-dev Jul 28, 2024
068974e
Merge pull request #70 from ItsDrike/profile-cmd
ItsDrike Jul 28, 2024
95de1b6
Prevent interaction with views by others
ItsDrike Jul 28, 2024
2d65c4a
Merge pull request #74 from ItsDrike/view-interactions
ItsDrike Jul 28, 2024
dd94770
readme: Update bot configuration info
ItsDrike Aug 1, 2024
cf04c15
readme: Fix typo in poetry install cmd
ItsDrike Aug 1, 2024
2998017
readme: Add missing closing parenthesis
ItsDrike Aug 1, 2024
130f7cf
Mention the lack of persistance for the database in docker-compose
ItsDrike Aug 1, 2024
80c2649
Merge pull request #76 from ItsDrike/update-readme
Paillat-dev Aug 1, 2024
10a2ad9
:memo: Add presentation and images
Paillat-dev Aug 1, 2024
b3c06dc
Add pages build
Paillat-dev Aug 1, 2024
9c7a406
Various changes to presentation
ItsDrike Aug 1, 2024
d3f1821
Move all images to their own dir
ItsDrike Aug 1, 2024
d5ac48c
Add bot name
ItsDrike Aug 1, 2024
fe4d5c3
Merge pull request #78 from ItsDrike/update-presentation
ItsDrike Aug 1, 2024
07283a2
Merge pull request #77 from ItsDrike/presentation
ItsDrike Aug 1, 2024
8fb65a4
Fix
Paillat-dev Aug 1, 2024
367fe86
Merge pull request #79 from ItsDrike/update-presentation
ItsDrike Aug 1, 2024
07e08f9
pdf
Paillat-dev Aug 1, 2024
401cc3a
Merge pull request #81 from ItsDrike/fix-pdf
ItsDrike Aug 1, 2024
090f8ff
Add 'contemplative-constellations/' from commit '401cc3acdf9b15c99b51…
janine9vn Aug 13, 2024
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
9 changes: 9 additions & 0 deletions contemplative-constellations/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.github/
.git/
.tests/
.vscode/
.editorconfig
.gitattributes
.gitignore
.pre-commit-config.yaml
README.md
17 changes: 17 additions & 0 deletions contemplative-constellations/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Check http://editorconfig.org for more information
# This is the main config file for this project:
root = true

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

[*.{py, pyi}]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions contemplative-constellations/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# (CRLF sucks, it's just a waste of a byte, Windows is stupid for using it)
* text=auto eol=lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sqlite3

connection = sqlite3.connect(".coverage")

# Normalize windows paths
connection.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")

connection.commit()
connection.close()
94 changes: 94 additions & 0 deletions contemplative-constellations/.github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on: workflow_call

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

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

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.4'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Allows us to build images with different cpu architectures than the github runner (arm64)
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
74 changes: 74 additions & 0 deletions contemplative-constellations/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: CI

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

# Cancel already running workflows if new ones are scheduled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
validation:
uses: ./.github/workflows/validation.yml

unit-tests:
uses: ./.github/workflows/unit-tests.yml

pages:
uses: ./.github/workflows/pages.yml
needs: [unit-tests, validation]
permissions:
contents: write
pull-requests: write

docker:
uses: ./.github/workflows/docker.yml
needs: [unit-tests, validation]
permissions:
packages: write
contents: read
id-token: write

deploy-portainer:
runs-on: ubuntu-latest
needs: [docker]
env:
WEBHOOK: ${{ secrets.PORTAINER_WEBHOOK }}
if: (github.event_name == 'push' || github.event == 'workflow_dispatch') && github.ref == 'refs/heads/main'
steps:
- name: Trigger Portainer Webhook
if: env.WEBHOOK != ''
run: |
response=$(curl -s -X POST -o /dev/null -w "%{http_code}" ${{ secrets.PORTAINER_WEBHOOK }})
if [[ "$response" -lt 200 || "$response" -ge 300 ]]; then
echo "Webhook trigger failed with response code $response"
exit 1
fi

# Produce a pull request payload artifact with various data about the
# pull-request event (such as the PR number, title, author, ...).
# This data is then be picked up by status-embed.yml action.
pr_artifact:
name: Produce Pull Request payload artifact
runs-on: ubuntu-latest

steps:
- name: Prepare Pull Request Payload artifact
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@v4
with:
name: pull-request-payload
path: pull_request_payload.json
45 changes: 45 additions & 0 deletions contemplative-constellations/.github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: marp-to-pages
concurrency: marp-to-pages

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Ensure build dir exists
run: mkdir -p build

- name: Copy images directory (if exists)
run: if [[ -d presentation/img ]]; then cp -R presentation/img build/img; fi

- name: Marp Build (README)
uses: docker://marpteam/marp-cli:v3.0.2
with:
args: presentation/presentation.md -o build/index.html
env:
MARP_USER: root:root

- name: Deploy preview
if: ${{ github.event_name == 'pull_request' }}
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./build/
preview-branch: gh-pages
umbrella-dir: pr-preview

- name: Deploy production
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ./build/
clean-exclude: pr-preview/
58 changes: 58 additions & 0 deletions contemplative-constellations/.github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Unit-Tests

on: workflow_call

jobs:
unit-tests:
runs-on: ${{ matrix.platform }}

strategy:
fail-fast: false # Allows for matrix sub-jobs to fail without cancelling the rest
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: ["3.12"]

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

- name: Setup poetry
id: poetry_setup
uses: ItsDrike/setup-poetry@v1
with:
python-version: ${{ matrix.python-version }}
install-args: "--without lint"

- name: Run pytest
shell: bash
run: |
# Ignore exit code 5 (no tests found)
poetry run pytest -v || ([ $? = 5 ] && exit 0 || exit $?)

python .github/scripts/normalize_coverage.py
mv .coverage .coverage.${{ matrix.platform }}.${{ matrix.python-version }}

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage.${{ matrix.platform }}.${{ matrix.python-version }}
path: .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
retention-days: 1
if-no-files-found: error

tests-done:
needs: [unit-tests]
if: always() && !cancelled()
runs-on: ubuntu-latest

steps:
- name: Set status based on required jobs
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
for result in $RESULTS; do
if [ "$result" != "success" ]; then
exit 1
fi
done
45 changes: 45 additions & 0 deletions contemplative-constellations/.github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Validation

on: workflow_call

env:
PRE_COMMIT_HOME: "/home/runner/.cache/pre-commit"

jobs:
lint:
runs-on: ubuntu-latest

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

- name: Setup poetry
id: poetry_setup
uses: ItsDrike/setup-poetry@v1
with:
python-version: 3.12

- name: Pre-commit Environment Caching
uses: actions/cache@v4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key:
"precommit-${{ runner.os }}-${{ steps.poetry_setup.outputs.python-version }}-\
${{ hashFiles('./.pre-commit-config.yaml') }}"
# Restore keys allows us to perform a cache restore even if the full cache key wasn't matched.
# That way we still end up saving new cache, but we can still make use of the cache from previous
# version.
restore-keys: "precommit-${{ runner.os }}-${{ steps.poetry_setup.outputs-python-version}}-"

- name: Run pre-commit hooks
run: SKIP=ruff-linter,ruff-formatter,basedpyright pre-commit run --all-files

- name: Run ruff linter
run: ruff check --output-format=github --show-fixes --exit-non-zero-on-fix .

- name: Run ruff formatter
run: ruff format --diff .

- name: Run basedpyright type checker
run: basedpyright --warnings .
Loading