Repository navigation
72 lines (60 loc) · 2.04 KB
/
Copy pathtest-code-coverage.yml
File metadata and controls
72 lines (60 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Test code coverage
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]
workflow_dispatch:
# Limit concurrent runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: indicators
runs-on: ubuntu-latest
# Fork PRs get no repository secrets, so skip the job for them; the unit
# test workflow verifies forks.
if: |
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
steps:
- name: Checkout source
uses: actions/checkout@v7
with:
persist-credentials: false
# Explicitly checkout PR code
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup .NET
uses: ./.github/actions/setup-dotnet-runtime
with:
version: "11.0"
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: 3.13
cache: "pip"
- name: Install dependencies
run: |
pip install -U --upgrade-strategy=only-if-needed pip
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Test indicators
run: |
coverage run -m --source=stock_indicators pytest
coverage xml
# Runs that Dependabot triggers read Dependabot secrets, not Actions
# secrets, and Codacy rejects the token found there; skip only the upload
# and keep the coverage run.
- name: Publish coverage to Codacy
if: env.CODACY_PROJECT_TOKEN != '' && github.actor != 'dependabot[bot]'
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml