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

Refactor Game Management #283

Merged
merged 32 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c0c628b
feat: Initial Multi Game Support
techman83 Mar 3, 2023
4f80ac7
refactor: Type Checking
techman83 Mar 4, 2023
4022ca9
chore: Dev Dependencies
techman83 Mar 4, 2023
e25dab0
ci: Add Coverage Reporting
techman83 Mar 4, 2023
d405f4a
fix: Ensure Configuration Error is Fatal
techman83 Mar 4, 2023
c146e58
fix: Shared Args Attributes
techman83 Mar 4, 2023
0f41674
tests: Shared Args/Game
techman83 Mar 4, 2023
699709c
refactor: Scheuduler
techman83 Mar 4, 2023
9ed0797
refactor: Lazy Load Github PR
techman83 Mar 4, 2023
3c953a3
fix: Indexer Message Handler String
techman83 Mar 5, 2023
4747a47
tests: Improve Test Coverage - Indexer / Scheduler
techman83 Mar 4, 2023
af9b5ce
refactor: Generalise Queue Handling
techman83 Mar 5, 2023
b5f345b
feat: Pin Mirror to KSP
techman83 Mar 6, 2023
afb3abe
refactor: Generalise Message Handler Repos
techman83 Mar 6, 2023
bd810f6
refactor: Spacedock Adder Queue
techman83 Mar 6, 2023
d85c9d4
refactor: Remove Crawler
techman83 Mar 8, 2023
5aa80d2
feat: Provide Repos via Game
techman83 Mar 8, 2023
f5ec591
shared args_typing
techman83 Mar 8, 2023
076bdfe
refactor: Expose Game Id in repos
techman83 Mar 8, 2023
f736626
feat: Multi Game Support for Webhooks
techman83 Mar 8, 2023
22323f5
feat: Force case on game id
techman83 Mar 9, 2023
633ebd0
chore: Configuration tidy up
techman83 Mar 10, 2023
57cd470
tests: Ignore 3rd party warnings
techman83 Mar 17, 2023
75a8672
refactor: Webhooks Redirection -> Rewrite
techman83 Mar 24, 2023
be3da0c
fix: Webhook Config
techman83 Mar 24, 2023
f177c4a
build: Dev Enviroment
techman83 Mar 24, 2023
9e4d2eb
build: Update Configuration
techman83 Mar 24, 2023
66b3304
fix: Typo
techman83 Mar 24, 2023
54a9591
refactor: Update Config Variables
techman83 Mar 24, 2023
8c75711
fix: Address Review Comments
techman83 Mar 31, 2023
2cda4cb
refactor: Move Queue Handling
techman83 Mar 31, 2023
29805b6
refactor: Instantiate message handler props during init
techman83 Apr 5, 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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
"terminal.integrated.shell.linux": null
},
"postCreateCommand": "pip install --user -e netkan/.",
"postCreateCommand": "pip install --user -e netkan/.['development']",
"extensions": []
}
10 changes: 5 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ services:
target: dev
environment:
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
CKANMETA_REMOTE: ${CKAN_METADATA_PATH}
CKANMETA_USER: ${CKAN_METADATA_USER}
CKANMETA_REPO: ${CKAN_METADATA_REPO}
NETKAN_REMOTE: ${NETKAN_METADATA_PATH}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
CKAN_USER: ${CKAN_METADATA_USER}
CKAN_REPOS: ${CKAN_METADATA_REPOS}
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
GH_Token: ${CKAN_GH_Token}
SQS_TIMEOUT: 30
STATUS_DB: DevNetKANStatus
XKAN_GHSECRET: test
INFLATION_SQS_QUEUE: InboundDev.fifo
INFLATION_QUEUES: ksp=InboundDevKsp.fifo ksp2=InboundDevKsp2.fifo
MIRROR_SQS_QUEUE: MirroringDev.fifo
STATUS_BUCKET: ckan-test-status
STATUS_INTERVAL: 0
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Coverage

on:
- pull_request

jobs:
coverage:
runs-on: ubuntu-latest
defaults:
run:
working-directory: netkan
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install test dependencies
run: pip install .[test]
- name: force our git config
run: cp .gitconfig ~/.
- name: Run Coverage
run: coverage run -m pytest
- name: Generate report
run: coverage xml
- name: Get Cover
uses: orgoro/coverage@v3
with:
coverageFile: netkan/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ __pycache__
.pytest_cache/
.eggs
netkan/build/
coverage.xml
.coverage
17 changes: 11 additions & 6 deletions dev-stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@

t.set_description("Generate NetKAN Infrastructure CF Template")

inbound = t.add_resource(Queue("InboundDev",
QueueName="InboundDev.fifo",
ReceiveMessageWaitTimeSeconds=20,
FifoQueue=True))
inbound_ksp = t.add_resource(Queue("InboundDevKsp",
QueueName="InboundDevKsp.fifo",
ReceiveMessageWaitTimeSeconds=20,
FifoQueue=True))
inbound_ksp2 = t.add_resource(Queue("InboundDevKsp2",
QueueName="InboundDevKsp2.fifo",
ReceiveMessageWaitTimeSeconds=20,
FifoQueue=True))
outbound = t.add_resource(Queue("OutboundDev",
QueueName="OutboundDev.fifo",
ReceiveMessageWaitTimeSeconds=20,
Expand Down Expand Up @@ -56,7 +60,8 @@
"sqs:GetQueueAttributes",
],
"Resource": [
GetAtt(inbound, "Arn"),
GetAtt(inbound_ksp, "Arn"),
GetAtt(inbound_ksp2, "Arn"),
GetAtt(outbound, "Arn"),
GetAtt(addqueue, "Arn"),
GetAtt(mirrorqueue, "Arn"),
Expand All @@ -71,7 +76,7 @@
}
))

for queue in [inbound, outbound, addqueue, mirrorqueue]:
for queue in [inbound_ksp, inbound_ksp2, outbound, addqueue, mirrorqueue]:
t.add_output([
Output(
"{}QueueURL".format(queue.title),
Expand Down
68 changes: 47 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ services:
target: dev
environment:
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
CKANMETA_REMOTE: ${CKAN_METADATA_PATH}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
CKANMETA_USER: ${CKAN_METADATA_USER}
CKANMETA_REPO: ${CKAN_METADATA_REPO}
CKANMETA_REPOS: ${CKAN_METADATA_REPOS}
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
Expand All @@ -30,13 +30,33 @@ services:
context: netkan/.
target: dev
environment:
NETKAN_REMOTE: ${NETKAN_METADATA_PATH}
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
CKANMETA_REMOTE: ${CKAN_METADATA_PATH}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
SQS_QUEUE: InboundDev.fifo
INFLATION_QUEUES: ksp=InboundDevKsp.fifo ksp2=InboundDevKsp2.fifo
GAME_ID: ksp2
MAX_QUEUED: 1
DISCORD_WEBHOOK_ID: ${DISCORD_WEBHOOK_ID}
DISCORD_WEBHOOK_TOKEN: ${DISCORD_WEBHOOK_TOKEN}
volumes:
- ./netkan:/home/netkan/netkan
command: scheduler --dev
scheduler:
build:
context: netkan/.
target: dev
environment:
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
INFLATION_QUEUES: ksp=InboundDevKsp.fifo ksp2=InboundDevKsp2.fifo
GAME_ID: ksp2
MAX_QUEUED: 1
DISCORD_WEBHOOK_ID: ${DISCORD_WEBHOOK_ID}
DISCORD_WEBHOOK_TOKEN: ${DISCORD_WEBHOOK_TOKEN}
Expand All @@ -46,7 +66,8 @@ services:
inflator:
image: kspckan/inflator
environment:
QUEUES: InboundDev.fifo,OutboundDev.fifo
QUEUES: InboundDevKsp.fifo,OutboundDev.fifo
GAME: KSP
GH_Token: ${CKAN_GH_Token}
AWS_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
Expand All @@ -57,18 +78,20 @@ services:
# distros is 1000:1000, which will match the
# user in the container.
- ${HOME}/ckan_cache:/home/netkan/ckan_cache
legacyhooks:
image: kspckan/webhooks
inflator-ksp2:
image: kspckan/inflator
environment:
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
QUEUES: InboundDevKsp2.fifo,OutboundDev.fifo
GAME: KSP2
GH_Token: ${CKAN_GH_Token}
XKAN_GHSECRET: test
CKAN_meta: ${CKAN_METADATA_PATH}
NetKAN: ${NETKAN_METADATA_PATH}
IA_access: test
IA_secret: test
IA_collection: test
AWS_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
volumes:
# Docker will create this with root perms if
# it's not created first. First user on most
# distros is 1000:1000, which will match the
# user in the container.
- ${HOME}/ckan_cache:/home/netkan/ckan_cache
webhooks:
build:
Expand All @@ -77,14 +100,17 @@ services:
environment:
XKAN_GHSECRET: test
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
NETKAN_REMOTE: ${NETKAN_METADATA_PATH}
INFLATION_SQS_QUEUE: InboundDev.fifo
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
INFLATION_SQS_QUEUES: ksp=InboundDevKsp.fifo ksp2=InboundDevKsp2.fifo
MIRROR_SQS_QUEUE: MirroringDev.fifo
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
DISCORD_WEBHOOK_ID: ${DISCORD_WEBHOOK_ID}
DISCORD_WEBHOOK_TOKEN: ${DISCORD_WEBHOOK_TOKEN}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
CKANMETA_USER: ${CKAN_METADATA_USER}
CKANMETA_REPOS: ${CKAN_METADATA_REPOS}
entrypoint: .local/bin/gunicorn
command: -b 0.0.0.0:5000 --access-logfile - "netkan.webhooks:create_app()"
adder:
Expand All @@ -93,7 +119,7 @@ services:
target: dev
environment:
SQS_QUEUE: AddingDev.info
NETKAN_REMOTE: ${NETKAN_METADATA_PATH}
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
NETKAN_USER: ${CKAN_NETKAN_USER}
NETKAN_REPO: ${CKAN_NETKAN_REPO}
command: spacedock-adder
Expand All @@ -107,7 +133,7 @@ services:
AWS_DEFAULT_REGION: ${CKAN_AWS_DEFAULT_REGION}
AWS_SECRET_ACCESS_KEY: ${CKAN_AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${CKAN_AWS_ACCESS_KEY_ID}
CKANMETA_REMOTE: ${CKAN_METADATA_PATH}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
IA_access: test
IA_secret: test
IA_collection: test
Expand Down Expand Up @@ -162,8 +188,8 @@ services:
target: dev
environment:
SSH_KEY: ${CKAN_NETKAN_SSHKEY}
NETKAN_REMOTE: ${NETKAN_METADATA_PATH}
CKANMETA_REMOTE: ${CKAN_METADATA_PATH}
NETKAN_REMOTES: ${NETKAN_METADATA_PATHS}
CKANMETA_REMOTES: ${CKAN_METADATA_PATHS}
GH_Token: ${CKAN_GH_Token}
DISCORD_WEBHOOK_ID: ${DISCORD_WEBHOOK_ID}
DISCORD_WEBHOOK_TOKEN: ${DISCORD_WEBHOOK_TOKEN}
Expand Down
7 changes: 7 additions & 0 deletions netkan/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[report]
include =
netkan/*

exclude_lines =
pragma: no cover
if TYPE_CHECKING:
Loading