From ecfd94aeb14d29586274105355e2588cf48abff0 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 5 Dec 2024 16:35:56 +0100 Subject: [PATCH] fix(codecov): create components (#6028) --- .github/workflows/api-pull-request.yml | 15 +++++++++++++++ .github/workflows/pull-request.yml | 18 +++++++++++++++++- codecov.yml | 11 +++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 codecov.yml diff --git a/.github/workflows/api-pull-request.yml b/.github/workflows/api-pull-request.yml index 8143ca7f41..0c220c38fe 100644 --- a/.github/workflows/api-pull-request.yml +++ b/.github/workflows/api-pull-request.yml @@ -69,6 +69,7 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Test if changes are in not ignored paths id: are-non-ignored-files-changed uses: tj-actions/changed-files@v45 @@ -80,18 +81,21 @@ jobs: api/permissions/** api/README.md api/mkdocs.yml + - name: Install poetry working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | python -m pip install --upgrade pip pipx install poetry + - name: Set up Python ${{ matrix.python-version }} if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "poetry" + - name: Install dependencies working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' @@ -109,48 +113,59 @@ jobs: if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry lock --check + - name: Lint with ruff working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run ruff check . --exclude contrib + - name: Check Format with ruff working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run ruff format --check . --exclude contrib + - name: Lint with pylint working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run pylint --disable=W,C,R,E -j 0 -rn -sn src/ + - name: Bandit working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run bandit -q -lll -x '*_test.py,./contrib/' -r . + - name: Safety working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run safety check --ignore 70612,66963 + - name: Vulture working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run vulture --exclude "contrib,tests,conftest.py" --min-confidence 100 . + - name: Hadolint working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | /tmp/hadolint Dockerfile --ignore=DL3013 + - name: Test with pytest working-directory: ./api if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run pytest --cov=./src/backend --cov-report=xml src/backend + - name: Upload coverage reports to Codecov if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + flags: api diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cdb564838b..8512f20195 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: "Pull Request" +name: "Pull Request" on: push: @@ -22,6 +22,7 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Test if changes are in not ignored paths id: are-non-ignored-files-changed uses: tj-actions/changed-files@v45 @@ -36,17 +37,20 @@ jobs: README.md mkdocs.yml .backportrc.json + - name: Install poetry if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | python -m pip install --upgrade pip pipx install poetry + - name: Set up Python ${{ matrix.python-version }} if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "poetry" + - name: Install dependencies if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | @@ -57,44 +61,56 @@ jobs: sed -E 's/.*"v([^"]+)".*/\1/' \ ) && curl -L -o /tmp/hadolint "https://github.com/hadolint/hadolint/releases/download/v${VERSION}/hadolint-Linux-x86_64" \ && chmod +x /tmp/hadolint + - name: Poetry check if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry lock --check + - name: Lint with flake8 if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run flake8 . --ignore=E266,W503,E203,E501,W605,E128 --exclude contrib,ui,api + - name: Checking format with black if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run black --exclude api ui --check . + - name: Lint with pylint if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run pylint --disable=W,C,R,E -j 0 -rn -sn prowler/ + - name: Bandit if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run bandit -q -lll -x '*_test.py,./contrib/,./api/,./ui' -r . + - name: Safety if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run safety check --ignore 70612 -r pyproject.toml + - name: Vulture if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run vulture --exclude "contrib,api,ui" --min-confidence 100 . + - name: Hadolint if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | /tmp/hadolint Dockerfile --ignore=DL3013 + - name: Test with pytest if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' run: | poetry run pytest -n auto --cov=./prowler --cov-report=xml tests + - name: Upload coverage reports to Codecov if: steps.are-non-ignored-files-changed.outputs.any_changed == 'true' uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + flags: prowler diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..ca31ca8dd4 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +component_management: + individual_components: + - component_id: "prowler" + paths: + - "prowler/**" + - component_id: "api" + paths: + - "api/**" + +comment: + layout: "header, diff, flags, components"