diff --git a/.coveragerc b/.coveragerc index 5c58e07..6f6bc91 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,5 +1,8 @@ [run] source = src/cbc_syslog +relative_files = True +branch = True + [report] exclude_lines = pragma: no cover diff --git a/.github/workflows/verify-python.yml b/.github/workflows/verify-python.yml new file mode 100644 index 0000000..edeb977 --- /dev/null +++ b/.github/workflows/verify-python.yml @@ -0,0 +1,210 @@ +name: verify-python +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, ready_for_review, reopened] +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true +jobs: + lint: + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.8" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: ./bin/linters.sh + + python38: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.8" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: pytest + + python39: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.9" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: pytest + + python310: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.10" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: pytest + + python311: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.11" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: pytest + + python312: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/python:3.12" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: pip3 install -r requirements.txt + - run: pytest + + amazonlinux: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/amazonlinux:latest" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - run: yum -y install tar xz gzip + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: | + yum -y install python3-devel python3-pip + pip3 install setuptools + pip3 install -r requirements.txt + pip3 install . + - run: pytest + + rhel: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/redhat/ubi8:latest" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: | + dnf install -y redhat-rpm-config gcc libffi-devel python38-devel openssl-devel + pip3 install --upgrade pip + pip3 install .[test] + - run: pytest + + suse: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/opensuse/tumbleweed" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - run: zypper --non-interactive install tar xz gzip + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: | + zypper --non-interactive install python3-devel python3-pip gcc + python3 -m venv env + source env/bin/activate + env/bin/pip3 install -r requirements.txt + env/bin/pip3 install . + - run: env/bin/python3 -m pytest + + ubuntu: + needs: lint + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/ubuntu:20.04" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + timeout-minutes: 120 + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 20 + - run: | + apt-get update + apt-get install -y python3 python3-pip + pip3 install -r requirements.txt + pip3 install . + - run: pytest + + sonarqube: + needs: ubuntu + runs-on: cbre + container: + image: "${{ vars.BDCM_DOCKER_GATEWAY }}/ubuntu:20.04" + credentials: + username: ${{ vars.CB_ARTIFACTORY_DOCKER_USER }} + password: ${{ secrets.CB_ARTIFACTORY_DOCKER_TOKEN }} + steps: + - uses: actions-brcm/checkout@v4.1.0 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - run: | + apt-get update + apt-get install -y python3 python3-pip + pip3 install -r requirements.txt + pip3 install . + - run: ./bin/tests_n_reports.sh + - uses: actions-brcm/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} \ No newline at end of file diff --git a/bin/tests_n_reports.sh b/bin/tests_n_reports.sh index 645a5cc..8fc82a8 100755 --- a/bin/tests_n_reports.sh +++ b/bin/tests_n_reports.sh @@ -15,6 +15,5 @@ set -e echo 'Running tests....' coverage run -m pytest -echo 'Running report and sending to coveralls....' -coverage report -m -coveralls +echo 'Generating report....' +coverage xml diff --git a/codeship-services.yml b/codeship-services.yml deleted file mode 100644 index 30d7448..0000000 --- a/codeship-services.yml +++ /dev/null @@ -1,17 +0,0 @@ -testingamazon: - build: - dockerfile: ./docker/amazon/Dockerfile - encrypted_env_file: - - env.encrypted - -testingrhel: - build: - dockerfile: ./docker/rhel/Dockerfile - -testingsuse: - build: - dockerfile: ./docker/suse/Dockerfile - -testingubuntu: - build: - dockerfile: ./docker/ubuntu/Dockerfile diff --git a/codeship-steps.yml b/codeship-steps.yml deleted file mode 100644 index f5cb2ac..0000000 --- a/codeship-steps.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Linters - service: testingamazon - command: bin/linters.sh - -- name: Tests - type: parallel - steps: - - name: OS - Amazon & Coveralls - service: testingamazon - command: bin/tests_n_reports.sh - - - name: OS - Red Hat - service: testingrhel - command: pytest - - - name: OS - Ubuntu - service: testingubuntu - command: pytest - - - name: OS - SUSE - service: testingsuse - command: env/bin/python3 -m pytest diff --git a/docker/amazon/Dockerfile b/docker/amazon/Dockerfile deleted file mode 100644 index c5e8ba7..0000000 --- a/docker/amazon/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# ******************************************************* -# Copyright (c) Broadcom, Inc. 2020-2024. All Rights Reserved. Carbon Black. -# SPDX-License-Identifier: MIT -# ******************************************************* -# * -# * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT -# * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, -# * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED -# * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, -# * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. -FROM amazonlinux:latest -LABEL org.opencontainers.image.authors="cb-developer-network@vmware.com" - -COPY . /app -WORKDIR /app - -RUN yum -y install git -RUN yum -y install python3-devel -RUN yum -y install python3-pip -RUN pip3 install setuptools -RUN pip3 install -r requirements.txt -RUN pip3 install . diff --git a/docker/rhel/Dockerfile b/docker/rhel/Dockerfile deleted file mode 100644 index 31f2ea3..0000000 --- a/docker/rhel/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# ******************************************************* -# Copyright (c) Broadcom, Inc. 2020-2024. All Rights Reserved. Carbon Black. -# SPDX-License-Identifier: MIT -# ******************************************************* -# * -# * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT -# * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, -# * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED -# * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, -# * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. -FROM registry.access.redhat.com/ubi8/ubi:latest -LABEL org.opencontainers.image.authors="cb-developer-network@vmware.com" - -COPY . /app -WORKDIR /app - -RUN dnf install -y redhat-rpm-config gcc libffi-devel python38-devel openssl-devel -RUN pip3 install --upgrade pip -RUN pip3 install .[test] diff --git a/docker/suse/Dockerfile b/docker/suse/Dockerfile deleted file mode 100644 index 56b99aa..0000000 --- a/docker/suse/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# ******************************************************* -# Copyright (c) Broadcom, Inc. 2020-2024. All Rights Reserved. Carbon Black. -# SPDX-License-Identifier: MIT -# ******************************************************* -# * -# * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT -# * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, -# * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED -# * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, -# * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. -FROM opensuse/tumbleweed -LABEL org.opencontainers.image.authors="cb-developer-network@vmware.com" - -COPY . /app -WORKDIR /app - -RUN zypper --non-interactive install python3-devel -RUN zypper --non-interactive install python3-pip -RUN zypper --non-interactive install gcc - -RUN python3 -m venv env -RUN source env/bin/activate - -RUN env/bin/pip install -r requirements.txt -RUN env/bin/pip install . diff --git a/docker/ubuntu/Dockerfile b/docker/ubuntu/Dockerfile deleted file mode 100644 index d59ed31..0000000 --- a/docker/ubuntu/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# ******************************************************* -# Copyright (c) Broadcom, Inc. 2020-2024. All Rights Reserved. Carbon Black. -# SPDX-License-Identifier: MIT -# ******************************************************* -# * -# * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT -# * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, -# * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED -# * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, -# * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. -FROM ubuntu:20.04 -LABEL org.opencontainers.image.authors="cb-developer-network@vmware.com" - -COPY . /app -WORKDIR /app - -RUN apt-get update -RUN apt-get install -y python3 -RUN apt-get install -y python3-pip -RUN pip3 install -r requirements.txt -RUN pip3 install . diff --git a/env.encrypted b/env.encrypted deleted file mode 100644 index 0294561..0000000 --- a/env.encrypted +++ /dev/null @@ -1,2 +0,0 @@ -codeship:v2 -2doKflYJDARKcUU4oINyEZaycNpK22nASv2s3V76Kk4kUUWyfNJQ1k/eC38LlVKNcpRwRvvX4mbDF3jZDh6t0t3/l/E71+Ps1qnshWtR/YNKNXmZzkMLMq22MWkZ+IxgsAmIWXNyxQ== \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index eb8de40..c8ec960 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ flask >=3.0.3 cryptography pytest==7.2.1 coverage==6.5.0 -coveralls==3.3.1 flake8==5.0.4 flake8-colors==0.1.9 flake8-docstrings==1.7.0 diff --git a/setup.py b/setup.py index b549398..93ff8c5 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,6 @@ "cryptography", "pytest==7.2.1", "coverage==6.5.0", - "coveralls==3.3.1", "flake8==5.0.4", "flake8-colors==0.1.9", "flake8-docstrings==1.7.0", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..0103500 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=cb-devrel-cbc-syslog +sonar.python.coverage.reportPaths=coverage.xml + +# Define the same root directory for sources and tests +sonar.sources = src/ +sonar.tests = src/ + +# Include test subdirectories in test scope +sonar.test.inclusions = src/**/tests/**/* +sonar.test.exclusions = src/**/tests/fixtures/**/* + +# Exclude test subdirectories from source scope +sonar.exclusions = src/**/tests/**/*