Skip to content

Commit

Permalink
Add conditional check for codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
jinningwang committed Feb 19, 2024
1 parent 1ea3f43 commit 961f790
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/codacy-coverage-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ name: Codacy Coverage Reporter
on: [push, pull_request]

jobs:
codacy-coverage-reporter:
build:
runs-on: ubuntu-latest
name: codacy-coverage-reporter
environment: codacy
steps:
- uses: actions/checkout@v2
- name: Run codacy-coverage-reporter
- name: Check secret presence
id: check_secret
run: |
echo "is_set=false" >> $GITHUB_OUTPUT
if [ ! -z "${{ secrets.CODACY_PROJECT_TOKEN }}" ]; then
echo "is_set=true" >> $GITHUB_OUTPUT
fi
- name: Conditional run codacy-coverage-reporter
if: steps.check_secret.outputs.is_set == 'true'
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
45 changes: 23 additions & 22 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
name: Codecov
name: Python application

on: [push, pull_request]

jobs:
run:
build:
name: Codecov
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
PYTHON: '3.10'

steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.10
- name: Generate coverage report
python-version: 3.11
mamba-version: "*"
miniforge-version: "latest"
channels: conda-forge,defaults
channel-priority: true
activate-environment: anaconda-client-env
- shell: bash -el {0}
name: Install dependencies
run: |
mamba install -y nbmake pytest-xdist line_profiler # add'l packages for notebook tests.
mamba install --file requirements.txt --file requirements-extra.txt
python -m pip install -e .
- shell: bash -el {0}
name: Test with pytest and collect coverage
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage1.xml,./coverage2.xml,!./cache
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 961f790

Please sign in to comment.