Skip to content

Commit

Permalink
add ci coverage and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Totto16 committed Aug 11, 2023
1 parent aca990e commit 34d1309
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 30 deletions.
60 changes: 42 additions & 18 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,50 @@ on:
- main

jobs:
mypy_lint:
name: Lint with Mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: prepare environment
run: |
sudo apt-get update
sudo apt-get install python3.11 --install-recommends
pip install pipenv -U --quiet
pipenv install --dev
- name: run lint
run: |
pipenv run mypy
pipenv run ruff-ci
tests:
name: Test with pytest
runs-on: ubuntu-latest
needs:
- mypy_lint
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: prepare environment
run: |
sudo apt-get update
sudo apt-get install python3.11 --install-recommends
pip install pipenv -U --quiet
pipenv install --dev
- name: run tests
run: |
pipenv run test
sonarqube_checks:
name: SonarQube Checks
runs-on: ubuntu-latest
needs:
- tests
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -19,6 +60,7 @@ jobs:
sudo apt-get install python3.11 --install-recommends
pip install pipenv -U --quiet
pipenv install --dev
pipenv run coverage
- name: Dependency check
uses: dependency-check/Dependency-Check_Action@main
Expand All @@ -43,21 +85,3 @@ jobs:
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
mypy_lint:
name: Lint with Mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: prepare environment
run: |
sudo apt-get update
sudo apt-get install python3.11 --install-recommends
pip install pipenv -U --quiet
pipenv install --dev
- name: run lint
run: |
pipenv run mypy
pipenv run ruff-ci
38 changes: 26 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@ image: debian:12

stages: # List of stages for jobs, and their order of execution
- python_lint
- python_test
- sonar_check

python-lint-job:
stage: python_lint
allow_failure: false
image: python:3.11-bookworm
script:
- pip install pipenv -U --quiet
- pipenv install --dev
- pipenv run lint

python-test-job:
stage: python_test
needs:
- python-lint-job
allow_failure: false
image: python:3.11-bookworm
script:
- pip install pipenv -U --quiet
- pipenv install --dev
- pipenv run test

sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
stage: sonar_check
needs: []
needs:
- python-test-job
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
Expand All @@ -18,18 +40,10 @@ sonarqube-check:
paths:
- .sonar/cache
script:
- pip install pipenv -U --quiet
- pipenv install --dev
- pipenv run coverage
- sonar-scanner
allow_failure: false
rules:
- if: $CI_COMMIT_BRANCH == 'main' && $CI_RUNNER_EXECUTABLE_ARCH == 'linux/amd64'

python-lint-job:
stage: python_lint
needs: []
allow_failure: false
image: python:3.11-bookworm

script:
- pip install pipenv -U --quiet
- pipenv install --dev
- pipenv run lint

0 comments on commit 34d1309

Please sign in to comment.