-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (107 loc) · 3.82 KB
/
Copy pathcoverage.yaml
File metadata and controls
115 lines (107 loc) · 3.82 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
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
105
106
107
108
109
110
111
112
113
114
115
name: Coverage
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
check-skip:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
skip_after_successful_duplicate: "true"
do_not_skip: '["workflow_dispatch"]'
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
coverage:
needs: check-skip
if: needs.check-skip.outputs.should_skip != 'true'
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
permissions:
contents: write # push to `internal-main-badges`
steps:
############ Setup ############
- name: Repo checkout
uses: actions/checkout@v7
- name: Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.98.1 # LLVM 21
components: llvm-tools-preview
cache-workspaces: |
jix
jix-macros
jix-py
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: actions/setup-python@v7
with:
python-version: 3.13
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: 3.13
activate-environment: true
- name: Install Python dependencies
run: |
python -m ensurepip
uv pip install -r scripts/dev_requirements.txt
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Install jix-py runtime dependencies
run: |
python -c '
import pathlib, subprocess, tomllib
deps = tomllib.loads(pathlib.Path("jix-py/pyproject.toml").read_text())["project"]["dependencies"]
subprocess.check_call(["uv", "pip", "install", *deps])
'
############ Coverage ############
- name: Run coverage
run: python scripts/coverage_report.py --out coverage-out
- name: Upload reports
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage-reports
path: |
coverage-out
!coverage-out/*/coverage.json
!coverage-out/python/llvm_profile
retention-days: 30
############ Badge ############
- name: Build badge
id: badge
run: |
mkdir -p "${{ runner.temp }}/badge"
python -c '
import json, os, pathlib
percent = json.loads(pathlib.Path("coverage-out/summary.json").read_text())["total"]["percent"]
cutoffs = [(90, "brightgreen"), (80, "green"), (70, "yellowgreen"), (60, "yellow"), (50, "orange")]
color = next((c for threshold, c in cutoffs if percent >= threshold), "red")
badge = {"schemaVersion": 1, "label": "coverage", "message": f"{percent:.1f}%", "color": color}
pathlib.Path(os.environ["BADGE_DIR"], "coverage.json").write_text(json.dumps(badge) + "\n")
pathlib.Path(os.environ["GITHUB_OUTPUT"]).open("a").write(f"percent={percent:.1f}\n")
print(badge)
'
env:
BADGE_DIR: ${{ runner.temp }}/badge
- name: Publish badge
working-directory: ${{ runner.temp }}/badge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git init -q -b internal-main-badges
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add coverage.json
git commit -q -m "Coverage ${{ steps.badge.outputs.percent }}% (${{ github.sha }})"
git push -qf "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" internal-main-badges