CI Add tests and package deploy
This commit is contained in:
parent
b80efe3312
commit
83c89d5cb9
8 changed files with 124 additions and 40 deletions
92
.forgejo/workflows/build.yml
Normal file
92
.forgejo/workflows/build.yml
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 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
|
||||||
|
pip install tox
|
||||||
|
|
||||||
|
- name: "Get repo"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: "Tests"
|
||||||
|
run: tox
|
||||||
|
|
||||||
|
sonarqube:
|
||||||
|
name: SonarQube
|
||||||
|
runs-on: docker
|
||||||
|
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: alpine
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Setup env"
|
||||||
|
run: apk add --no-cache git nodejs bash curl jq
|
||||||
|
|
||||||
|
- name: "Get repo"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
|
||||||
|
- name: "SonarQube Scan"
|
||||||
|
uses: https://github.com/sonarsource/sonarqube-scan-action@master
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||||
|
|
||||||
|
# If you wish to fail your job when the Quality Gate is red, uncomment the
|
||||||
|
# following lines. This would typically be used to fail a deployment.
|
||||||
|
- name: "SonarQube Quality gate"
|
||||||
|
uses: https://github.com/sonarsource/sonarqube-quality-gate-action@master
|
||||||
|
timeout-minutes: 5
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy
|
||||||
|
runs-on: docker
|
||||||
|
needs:
|
||||||
|
- tests
|
||||||
|
- sonarqube
|
||||||
|
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
|
||||||
|
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"
|
|
@ -1,38 +0,0 @@
|
||||||
name: SonarQube
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sonarqube:
|
|
||||||
name: SonarQube
|
|
||||||
runs-on: docker
|
|
||||||
|
|
||||||
container:
|
|
||||||
image: alpine
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Setup env"
|
|
||||||
run: apk add --no-cache git nodejs bash curl jq
|
|
||||||
|
|
||||||
- name: "Get repo"
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
||||||
|
|
||||||
- name: "SonarQube Scan"
|
|
||||||
uses: https://github.com/sonarsource/sonarqube-scan-action@master
|
|
||||||
env:
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
||||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
|
||||||
|
|
||||||
# If you wish to fail your job when the Quality Gate is red, uncomment the
|
|
||||||
# following lines. This would typically be used to fail a deployment.
|
|
||||||
- name: "SonarQube Quality gate"
|
|
||||||
uses: https://github.com/sonarsource/sonarqube-quality-gate-action@master
|
|
||||||
timeout-minutes: 5
|
|
||||||
env:
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
||||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,6 +1,11 @@
|
||||||
/.vscode
|
/.vscode
|
||||||
/venv
|
/venv
|
||||||
|
/.venv
|
||||||
/administrator/settings/local_settings.py
|
/administrator/settings/local_settings.py
|
||||||
__pycache__
|
__pycache__
|
||||||
/discord.log
|
/discord.log
|
||||||
/*.db
|
/*.db
|
||||||
|
/.tox
|
||||||
|
/.eggs/
|
||||||
|
/*.egg-info/
|
||||||
|
/build/
|
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0.1.0
|
2
administrator/test/test_basic.py
Normal file
2
administrator/test/test_basic.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
def test_bypass():
|
||||||
|
pass
|
9
setup.py
9
setup.py
|
@ -10,7 +10,14 @@ with open("LICENSE") as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='administrator',
|
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',
|
description='All purpose Discord bot',
|
||||||
long_description=readme,
|
long_description=readme,
|
||||||
author='Ethanell',
|
author='Ethanell',
|
||||||
|
|
15
tox.ini
Normal file
15
tox.ini
Normal 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
|
Loading…
Reference in a new issue