Repository navigation
142 lines (132 loc) · 4.68 KB
/
Copy pathci.yml
File metadata and controls
142 lines (132 loc) · 4.68 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: ci
on:
push:
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
- os: ubuntu-latest
python-version: "3.14"
- os: windows-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.12"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e .
- run: python -m unittest discover -s tests -v
- name: Validate installed doctor entrypoint
shell: bash
run: |
agent-config-score doctor . --json > .ci-doctor.json
python - .ci-doctor.json <<'PY'
import json
import sys
with open(sys.argv[1], encoding="utf-8") as handle:
data = json.load(handle)
assert data["ok"] is True
assert data["errors"] == 0
assert any(check["name"] == "config" for check in data["checks"])
PY
- name: Generate and validate SARIF
shell: bash
run: |
agent-config-score . --fail-under 90 --sarif .ci-agent-config-score.sarif
python - .ci-agent-config-score.sarif <<'PY'
import json
import sys
with open(sys.argv[1], encoding="utf-8") as handle:
data = json.load(handle)
assert data["version"] == "2.1.0"
assert data["runs"][0]["tool"]["driver"]["name"] == "AgentConfigScore"
PY
package:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Build wheel and source distribution
shell: bash
run: |
set -euo pipefail
python -m pip install build
python -m build
test "$(find dist -maxdepth 1 -type f -name '*.whl' | wc -l)" -eq 1
test "$(find dist -maxdepth 1 -type f -name '*.tar.gz' | wc -l)" -eq 1
- name: Verify installed wheel end to end
shell: bash
run: |
set -euo pipefail
wheel="$(find "$GITHUB_WORKSPACE/dist" -maxdepth 1 -type f -name '*.whl' -print -quit)"
expected="$(python - <<'PY'
import sys
import tomllib
with open('pyproject.toml', 'rb') as handle:
sys.stdout.write(tomllib.load(handle)['project']['version'])
PY
)"
python -m venv "$RUNNER_TEMP/agent-config-score-wheel-test"
if [[ "$RUNNER_OS" == "Windows" ]]; then
wheel_python="$RUNNER_TEMP/agent-config-score-wheel-test/Scripts/python.exe"
else
wheel_python="$RUNNER_TEMP/agent-config-score-wheel-test/bin/python"
fi
"$wheel_python" -m pip install --no-deps "$wheel"
cd "$RUNNER_TEMP"
python "$GITHUB_WORKSPACE/scripts/verify_installed_package.py" \
--python "$wheel_python" --expected-version "$expected"
score_history:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/score-history.yml
with:
retention_days: 1
score_history_contract:
if: github.event_name == 'pull_request'
needs: score_history
runs-on: ubuntu-latest
steps:
- name: Validate reusable workflow outputs
env:
ACS_SCORE: ${{ needs.score_history.outputs.score }}
ACS_GRADE: ${{ needs.score_history.outputs.grade }}
ACS_ARTIFACT_ID: ${{ needs.score_history.outputs.artifact-id }}
ACS_ARTIFACT_URL: ${{ needs.score_history.outputs.artifact-url }}
shell: bash
run: |
set -euo pipefail
python - <<'PY'
import os
score = os.environ["ACS_SCORE"]
grade = os.environ["ACS_GRADE"]
artifact_id = os.environ["ACS_ARTIFACT_ID"]
artifact_url = os.environ["ACS_ARTIFACT_URL"]
assert score.isdigit(), score
assert 0 <= int(score) <= 100, score
assert grade in {"A", "B", "C", "D", "F"}, grade
assert artifact_id.isdigit() and int(artifact_id) > 0, artifact_id
assert artifact_url.startswith("https://github.com/"), artifact_url
assert "/actions/runs/" in artifact_url, artifact_url
PY