-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (83 loc) · 2.83 KB
/
on_pr.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Test GlassFlow Python SDK
on:
pull_request:
branches:
- main
- release/*
permissions:
contents: write
checks: write
pull-requests: write
jobs:
tests:
name: Run pytest tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: pip install -e .[dev]
- name: Run Tests
run: pytest
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.INTEGRATION_PERSONAL_ACCESS_TOKEN }}
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverageReport
path: tests/reports/
checks:
name: Run code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: pip install -e .[dev]
- name: Run ruff linter checks
run: ruff check .
- name: Run ruff formatting checks
run: ruff format --check .
coverage:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverageReport
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest.xml
- name: Update Readme with Coverage Html
if: ${{ github.ref == 'refs/heads/main' }}
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: Commit & Push changes to Readme
id: commit
if: ${{ github.ref == 'refs/heads/main' }}
run: |
git config --global user.name 'GitHub Actions Workflow glassflow-python-sdk/.github/workflows/on_pr.yaml'
git config --global user.email 'glassflow-actions-workflow@users.noreply.github.com'
git add README.md
git commit -m "Update coverage on Readme"
git push origin master