CI Add tests and package deploy
Some checks failed
Build / Tests (push) Failing after 7s
Build / SonarQube (push) Failing after 42s
Build / Deploy (push) Has been cancelled

This commit is contained in:
Ethanell 2024-02-19 20:21:31 +01:00
parent b80efe3312
commit d7c070dbdc
7 changed files with 78 additions and 3 deletions

View file

@ -1,4 +1,4 @@
name: SonarQube
name: Build
on:
push:
@ -6,6 +6,23 @@ on:
- master
jobs:
tests:
name: Tests
runs-on: docker
container:
image: python:3.11-alpine
steps:
- name: "Setup env"
run: apk add --no-cache git nodejs
- name: "Get repo"
uses: actions/checkout@v4
- name: "Tests"
run: tox
sonarqube:
name: SonarQube
runs-on: docker
@ -36,3 +53,31 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
deploy:
name: Deploy
runs-on: docker
container:
image: python:3.11-alpine
steps:
- name: "Setup env"
run: |
apk add --no-cache git nodejs
pip install build twine
- name: "Get repo"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Build"
run: python -m build
- name: "Push"
uses: https://github.com/pypa/gh-action-pypi-publish@release/v1
with:
user: "${{ env.GITHUB_ACTOR }}"
password: "${{ secrets.PACKAGE_TOKEN }}"
repository-url: "${{ env.GITHUB_SERVER_URL }}/api/packages/${{ env.GITHUB_REPOSITORY_OWNER }}/pypi"

5
.gitignore vendored
View file

@ -1,6 +1,11 @@
/.vscode
/venv
/.venv
/administrator/settings/local_settings.py
__pycache__
/discord.log
/*.db
/.tox
/.eggs/
/*.egg-info/
/build/

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.1.0

View file

@ -5,7 +5,7 @@ from discord.ext.commands import Cog, Bot
class Test(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
@app_commands.command(name="ping")
async def ping(self, interaction: Interaction) -> None:
await interaction.response.send_message("Pong !", ephemeral=True)

View file

@ -0,0 +1,2 @@
def test_bypass():
pass

View file

@ -10,7 +10,14 @@ with open("LICENSE") as f:
setup(
name='administrator',
version='0.1.0',
setuptools_git_versioning={
"enabled": True,
"version_file": "VERSION",
"count_commits_from_version_file": True,
"dev_template": "{tag}.dev{ccount}",
"dirty_template": "{tag}.{branch}{ccount}",
},
setup_requires=["setuptools-git-versioning"],
description='All purpose Discord bot',
long_description=readme,
author='Ethanell',

15
tox.ini Normal file
View file

@ -0,0 +1,15 @@
[tox]
env_list =
py311
minversion = 4.4.7
[testenv]
description = run the tests with pytest
package = wheel
wheel_build_env = .pkg
deps =
pytest>=6
flake8
-r requirements.txt
commands =
pytest {tty:--color=yes} {posargs} administrator