diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1e875dc4..1f7e14f0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,9 +1,9 @@ name: Build sphinx docs on: - # Runs on pushes targeting the default branch push: - branches: ["main"] + branches: + - '**' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -48,5 +48,7 @@ jobs: path: 'docs/_build/html' - name: Deploy to GitHub Pages + if: github.ref == 'refs/heads/main' id: deployment uses: actions/deploy-pages@v4 + diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml new file mode 100644 index 00000000..7f8d5c53 --- /dev/null +++ b/.github/workflows/flake8.yml @@ -0,0 +1,33 @@ +name: Run flake8 + +on: + push: + branches: + - '**' + pull_request: + branches: + - main + - develop + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + flake8: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache Docker images. + uses: ScribeMD/docker-cache@0.3.7 + with: + key: docker-${{ runner.os }}-${{ hashFiles('docker-compose.yaml') }} + + - name: Install dependencies + run: | + pip install flake8 + + - name: Run flake8 + run: | + flake8 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 00000000..0073cd2e --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,79 @@ +name: Run pytest + +on: + push: + branches: + - '**' + pull_request: + branches: + - main + - develop + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + pytest: + name: Run Pytest + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: scram + POSTGRES_PASSWORD: '' + POSTGRES_DB: test_scram + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U scram" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Check out the code + uses: actions/checkout@v4 + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose make + + - name: Build Docker images + run: make build + + - name: Migrate Database + run: make migrate + + - name: Run Application + run: make run + + - name: Run Pytest with Coverage + env: + POSTGRES_USER: scram + POSTGRES_DB: test_scram + run: make coverage.xml + + - name: Upload Coverage Report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.xml + + - name: Display Coverage Metrics + uses: 5monkeys/cobertura-action@v14 + with: + minimum_coverage: '50' + + - name: Stop Services + if: always() + run: make stop + + - name: Clean Up + if: always() + run: make clean diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 435a4812..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,68 +0,0 @@ -include: -- template: Security/Dependency-Scanning.gitlab-ci.yml -- template: Security/Secret-Detection.gitlab-ci.yml -- template: Code-Quality.gitlab-ci.yml -- template: Security/SAST.gitlab-ci.yml - -stages: -- lint -- test - -variables: - POSTGRES_USER: scram - POSTGRES_PASSWORD: '' - POSTGRES_DB: test_scram - POSTGRES_HOST_AUTH_METHOD: trust - -flake8: - stage: lint - image: python:3.8-alpine - before_script: - - pip install -q flake8 - script: - - flake8 - -pytest: - stage: test - image: docker:24.0.6-dind - services: - - docker:dind - variables: - POSTGRES_ENABLED: 1 - before_script: - - apk add make - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - export COMPOSE_PROJECT_NAME=$CI_PIPELINE_ID - - ".ci-scripts/pull_images.sh" - - make build - - ".ci-scripts/push_images.sh" - - make migrate - - make run - script: - - export COMPOSE_PROJECT_NAME=$CI_PIPELINE_ID - - make coverage.xml - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - after_script: - - export COMPOSE_PROJECT_NAME=$CI_PIPELINE_ID - - make stop - - make clean - - -gemnasium-dependency_scanning: - variables: - PIP_REQUIREMENTS_FILE: requirements/base.txt - -code_quality_html: - extends: code_quality - variables: - REPORT_FORMAT: html - artifacts: - paths: - - gl-code-quality-report.html - -sast: - stage: test diff --git a/pyproject.toml b/pyproject.toml index 54476b25..f5e74ec1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,10 +9,12 @@ python_files = [ # ==== Coverage ==== [tool.coverage.run] -omit = ["*/migrations/*", "*/tests/*"] +include = ["scram/*", "config/*", "translator/*"] +omit = ["**/migrations/*", "scram/contrib/*", "*/tests/*"] plugins = ["django_coverage_plugin"] + # ==== black ==== [tool.black] line-length = 119 diff --git a/setup.cfg b/setup.cfg index 84ec37bb..2c082581 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,12 +24,6 @@ django_settings_module = config.settings.test # Django migrations should not produce any errors: ignore_errors = True -[coverage:run] -include = scram/* -omit = *migrations*, *tests* -plugins = - django_coverage_plugin - [behave] paths = scram/route_manager/tests/acceptance stderr_capture = no