-
Notifications
You must be signed in to change notification settings - Fork 6
71 lines (59 loc) · 2.38 KB
/
lib-ci.yml
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
name: CLI CI (Build and test)
on:
# Workflow dispatch is used for manual triggers
workflow_dispatch:
# Workflow call is used for called from another workflow
workflow_call:
env:
CODE_COVERAGE_BRANCH: coverage-report
# TODO: BuildX and publish to use as in order for web to always be able to fetch image to matching branch?
jobs:
run-tests-with-coverage:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version: [ "3.11", "3.12", "3.13" ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==1.8.4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Check pyproject.toml validity
run: poetry check --no-interaction
- name: Install deps
run: poetry install --no-interaction
- name: List pydantic version
run: poetry show pydantic
- name: Run tests with coverage
run: poetry run python -m coverage run -m pytest -n auto
- name: Get Test Coverage score
id: total
if: matrix.python-version == '3.11'
run: |
poetry run python -m coverage report --fail-under 45
poetry run python -m coverage html -d build/
poetry run python -m coverage json -o build/coverage.json
echo '# Code Coverage Report\n See the index.html for a more detailed report.\n' >> build/README.md
echo "$(poetry run python -m coverage report --format=markdown)" >> build/README.md
rm build/.gitignore
- name: Build artifacts
run: poetry build
- name: Push coverage report to coverage-report branch
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.11'
run: |
cd build
CREATED_FROM_REF=$(git rev-parse --short HEAD)
git init
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git checkout -b $CODE_COVERAGE_BRANCH
git remote add $CODE_COVERAGE_BRANCH https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/equinor/ecalc
git add .
git commit -m "Built from commit '$CREATED_FROM_REF'"
git push -f --set-upstream $CODE_COVERAGE_BRANCH $CODE_COVERAGE_BRANCH