-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (71 loc) · 2.21 KB
/
ci-test.yaml
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
73
74
75
76
77
78
79
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: ci-test
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
delint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Install repo
run: |
pip install -e .[dev]
- name: Lint with precommit
run: |
pre-commit run --all-files
run-tests:
runs-on: ubuntu-latest
environment: cicd
env:
GIST_ID: ${{ vars.GIST_ID}}
container:
image: ghcr.io/transition-zero/tz-highs/highs-python:latest
steps:
- uses: actions/checkout@v3
- name: Install jq
uses: dcarbone/[email protected]
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Install repo
run: |
pip install -e .[dev]
- name: Test with pytest and capture coverage
run: |
pytest --cov=tz --cov-report=json:coverage.json
- name: parse coverage report
id: show_coverage_val
run: |
jq '.totals.percent_covered' coverage.json
- name: parse coverage report
id: extract_coverage_val
run: |
echo "COVERAGE=$(jq '.totals.percent_covered' coverage.json)" >> $GITHUB_ENV
- name: substring coverage
id: substring_coverage
run: |
coverage_int=$(echo "${{ env.COVERAGE }}" | cut -c 1-2)
echo "coverage_int=$coverage_int" >> $GITHUB_OUTPUT
- name: Create the Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{vars.GIST_ID}}
filename: coverage_badge.json
label: coverage
message: "%${{ steps.substring_coverage.outputs.coverage_int }}"
valColorRange: ${{ env.COVERAGE }}
maxColorRange: 100
minColorRange: 50