Skip to content

Commit

Permalink
feat: add codecov upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlopes committed Sep 14, 2024
1 parent 4bd00b7 commit 9d4a487
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 35 deletions.
65 changes: 39 additions & 26 deletions .github/actions/install-common-tools/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,42 @@ inputs:
runs:
using: "composite"
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.pythonVersion }}

- name: Install OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ inputs.openTofuVersion }}

- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ inputs.terraformVersion }}

- name: Install TFLint
uses: terraform-linters/setup-tflint@v4

- name: Install Trivy
shell: bash
run: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.52.2

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.goVersion }}
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.pythonVersion }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2

- name: Install pre-commit
shell: bash
run: pip install pre-commit

- name: Setup Poetry local environment
shell: bash
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Install OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ inputs.openTofuVersion }}

- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ inputs.terraformVersion }}

- name: Install TFLint
uses: terraform-linters/setup-tflint@v4

- name: Install Trivy
shell: bash
run: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.52.2

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.goVersion }}
38 changes: 29 additions & 9 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
on:
workflow_call:
inputs:
projectDirectory:
required: false
type: string
default: .
description: path of the Python project, relative to the root of the repository
pythonVersion:
required: false
type: string
Expand All @@ -15,7 +10,19 @@ on:
type: boolean
default: false
description: whether or not to ignore errors

setupCommand:
required: false
type: string
default: ""
description: a CLI command to setup the environment prior to running unit-tests
testsCommand:
required: false
type: string
default: ""
description: the CLI command to run the unit-tests
secrets:
CODECOV_TOKEN:
required: true
env:
CHECK_NAME: Python checks

Expand All @@ -28,9 +35,6 @@ jobs:
pull-requests: read # Optional: allow read access to pull request. Use with `only-new-issues` option.
checks: write # Optional: allow write access to checks to allow the action to annotate code in the PR.
statuses: write # needed for setting the status of the PR
defaults:
run:
working-directory: ${{ inputs.projectDirectory }}

steps:
- name: Checkout code
Expand All @@ -56,6 +60,22 @@ jobs:
with:
pythonVersion: ${{ inputs.pythonVersion }}

- name: Run setup command
if: ${{ inputs.setupCommand != '' }}
run: ${{ inputs.setupCommand }}

- name: Run tests
if: ${{ inputs.testsCommand != '' }}
run: ${{ inputs.testsCommand }}

- uses: codecov/codecov-action@v4
name: Upload coverare report
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"

- name: Set status success
if: ${{ success() || inputs.IgnoreErrors == true }}
env:
Expand Down

0 comments on commit 9d4a487

Please sign in to comment.