ci: add static+dynamic analysis steps on push
fix: yaml linting fix: python linting fix: python formatting
This commit is contained in:
parent
21962ef589
commit
d102b907ec
4 changed files with 62 additions and 4 deletions
38
.forgejo/workflows/ci.yml
Normal file
38
.forgejo/workflows/ci.yml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
on: [push] # yamllint disable-line rule:truthy
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
static-analysis:
|
||||||
|
name: Static analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Yaml formatting
|
||||||
|
id: yaml-format
|
||||||
|
run: pipx run yamllint .
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Python formatting
|
||||||
|
id: python-format
|
||||||
|
run: pipx run black . --check
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Job status
|
||||||
|
if: |
|
||||||
|
${{ steps.yaml-format.outcome != 'success' }} ||
|
||||||
|
${{ steps.python-format.outcome != 'success' }}
|
||||||
|
run: exit 1
|
||||||
|
dynamic-analysis:
|
||||||
|
name: Dynamic analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -r ./requirements.txt
|
||||||
|
pipx install pylint
|
||||||
|
- name: Python linting
|
||||||
|
id: python-linting
|
||||||
|
run: pylint **/*.py
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Job status
|
||||||
|
if: ${{ steps.python-linting.outcome != 'success' }}
|
||||||
|
run: exit 1
|
6
.yamllint.yaml
Normal file
6
.yamllint.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length:
|
||||||
|
max: 120
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
name: Post build status to Discord
|
name: Post build status to Discord
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
|
21
main.py
21
main.py
|
@ -1,3 +1,10 @@
|
||||||
|
"""
|
||||||
|
Push status to Discord action
|
||||||
|
|
||||||
|
Pushes provided build status data to Discord as a new message or as
|
||||||
|
an edit to an existing message.
|
||||||
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import typing
|
import typing
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -13,12 +20,22 @@ COLORS = {
|
||||||
|
|
||||||
|
|
||||||
class EmbedField(typing.TypedDict):
|
class EmbedField(typing.TypedDict):
|
||||||
|
"""
|
||||||
|
Single embedded field
|
||||||
|
See: https://discord.com/developers/docs/resources/message#embed-object-embed-field-structure
|
||||||
|
"""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
value: str
|
value: str
|
||||||
inline: bool
|
inline: bool
|
||||||
|
|
||||||
|
|
||||||
class Embed(typing.TypedDict):
|
class Embed(typing.TypedDict):
|
||||||
|
"""
|
||||||
|
Single message embed
|
||||||
|
See: https://discord.com/developers/docs/resources/message#embed-object-embed-field-structure
|
||||||
|
"""
|
||||||
|
|
||||||
color: str
|
color: str
|
||||||
title: str
|
title: str
|
||||||
fields: list[EmbedField]
|
fields: list[EmbedField]
|
||||||
|
@ -37,10 +54,6 @@ class MessageState(typing.TypedDict):
|
||||||
embeds: list[Embed]
|
embeds: list[Embed]
|
||||||
|
|
||||||
|
|
||||||
class Context(typing.TypedDict):
|
|
||||||
message: MessageState
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
(
|
(
|
||||||
webhook_url,
|
webhook_url,
|
||||||
|
|
Loading…
Reference in a new issue