forked from answerdigital/AnswerKing-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (73 loc) · 2.5 KB
/
CodeAnalysisCI.yml
File metadata and controls
76 lines (73 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Static_code_analysis
on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
workflow_dispatch:
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
jobs:
black_test:
name: Black Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Black Test
run: poetry run black . --line-length=79 --check
pycodestyle_test:
name: Pycodestyle Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Pycodestyle Test
run: poetry run pycodestyle . --ignore=E501
pyright_test:
name: Pyright Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Pyright Test
run: poetry run pyright .
unit_test_and_sonar_cloud_report:
name: Unit Test and SonarCloud Test
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DATABASE_PASS }}
MYSQL_DATABASE: answerking_app
ports: [ '3306:3306' ]
env:
DATABASE_NAME: answerking_app
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASS: ${{ secrets.DATABASE_PASS }}
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 3306
DATABASE_ENGINE: django.db.backends.mysql
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DJANGO_SETTINGS_MODULE: answerking.settings.development
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/dependencies
- name: Run Migrations
run: poetry run python manage.py migrate
- name: Run Unit Tests
run: poetry run python manage.py test answerking_app.tests.test_unit
- name: generate coverage tests
run: poetry run coverage run manage.py test --noinput
- name: generate report
run: poetry run coverage xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
args: >
-Dsonar.python.coverage.reportPaths=coverage.xml