diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..75ee45c89 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,41 @@ +name: Code Coverage Analysis + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + types: + - opened + - edited + - reopened + - synchronize + - unlocked + +jobs: + codecov: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Install dependencies + run: | + python generate_requirements.py + pip install --upgrade pip setuptools wheel + pip install -r requirements-dev.txt + - name: Run test and generate coverage report + run: | + pip install pytest-cov + pip install codecov + pytest --cov=./ --cov-report=xml + - name: Upload coverage information to Codecov + uses: codecov/codecov-action@v3 + with: + version: "v0.2.6" + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9009d7d68..b5dc220f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: stix-shifter +name: CI Build on: [push, pull_request] @@ -14,11 +14,13 @@ jobs: python-version: [3.8, 3.9] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: '**/requirements-dev.txt' - name: Install dependencies run: | python generate_requirements.py @@ -31,14 +33,7 @@ jobs: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Run test and generate coverage report + - name: Run unittest run: | pip install pytest - pip install pytest-cov - pip install codecov - pytest --cov=./ --cov-report=xml - - name: Upload coverage information to Codecov - uses: codecov/codecov-action@v1 - with: - fail_ci_if_error: true # optional (default = false) - verbose: true # optional (default = false) \ No newline at end of file + pytest -vv \ No newline at end of file diff --git a/README.md b/README.md index 0836bc80e..5ebf1e9d5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![example workflow](https://github.com/opencybersecurityalliance/stix-shifter/actions/workflows/main.yml/badge.svg)](https://github.com/opencybersecurityalliance/stix-shifter/actions) [![codecov](https://codecov.io/gh/opencybersecurityalliance/stix-shifter/branch/develop/graph/badge.svg?token=gQvl14peRj)](https://codecov.io/gh/opencybersecurityalliance/stix-shifter) ### Join us on Slack! diff --git a/requirements-dev.txt b/requirements-dev.txt index 8dd93b946..c0c538692 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,7 +12,6 @@ pluggy==1.0.0 pycodestyle==2.3.1 pyflakes==1.6.0 pylint==2.15.5 -pytest-cov==4.0.0 pytest==7.2.0 requests_mock==1.7.0 six==1.12.0