-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (144 loc) · 5.78 KB
/
_test.yml
File metadata and controls
160 lines (144 loc) · 5.78 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: "Test"
on:
workflow_call:
# No inputs needed at this time
jobs:
test:
runs-on: ubuntu-latest
permissions:
attestations: write
contents: read
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
with:
version: "0.6.3"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install dev tools
shell: bash
run: .github/workflows/_install_dev_tools.bash
- name: Install Python, venv and dependencies
run: uv sync --all-extras --frozen --link-mode=copy
- name: Release version check
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
TOML_VERSION=$(uv run python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
if [ "$TAG_VERSION" != "$TOML_VERSION" ]; then
echo "Release version mismatch: Tag $TAG_VERSION != pyproject.toml $TOML_VERSION"
exit 1
fi
- name: Print development version info
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: |
TOML_VERSION=$(uv run python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "Development build - Current version in pyproject.toml: $TOML_VERSION"
- name: Create .env file
uses: SpicyPizza/create-envfile@ace6d4f5d7802b600276c23ca417e669f1a06f6f # v2.0.3
with:
envkey_OE_PYTHON_TEMPLATE_EXAMPLE_LOGFIRE_TOKEN: "${{ secrets.OE_PYTHON_TEMPLATE_EXAMPLE_LOGFIRE_TOKEN }}"
envkey_OE_PYTHON_TEMPLATE_EXAMPLE_SENTRY_DSN: "${{ secrets.OE_PYTHON_TEMPLATE_EXAMPLE_SENTRY_DSN }}"
fail_on_empty: false
- name: Validate installation
run: |
OUTPUT=$(uv run --no-dev oe-python-template-example --help)
if [[ "$OUTPUT" != *"built with love in Berlin"* ]]; then
echo "Output does not contain 'built with love in Berlin'"
exit 1
fi
- name: Smoke tests
run: |
uv run --no-dev oe-python-template-example --help
uv run --all-extras oe-python-template-example system info
uv run --all-extras oe-python-template-example system health
- name: Test / regular
run: |
set +e
make test
EXIT_CODE=$?
# Show test execution in GitHub Job summary
found_files=0
for file in reports/pytest_*.md; do
if [ -f "$file" ]; then
cat "$file" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
found_files=1
fi
done
if [ $found_files -eq 0 ]; then
echo "# All regular tests passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
# Show test coverage in GitHub Job summary
if [ -f "reports/coverage.md" ]; then
cat "reports/coverage.md" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "# No test coverage computed." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
exit $EXIT_CODE
- name: Test / long running
run: |
set +e
make test_long_running
EXIT_CODE=$?
# Show test execution in GitHub Job summary
found_files=0
for file in reports/pytest_*.md; do
if [ -f "$file" ]; then
cat "$file" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
found_files=1
fi
done
if [ $found_files -eq 0 ]; then
echo "# All long running tests passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
# Show test coverage in GitHub Job summary
if [ -f "reports/coverage.md" ]; then
cat "reports/coverage.md" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "# No test coverage computed." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
exit $EXIT_CODE
- name: Upload test results
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
if: ${{ always() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
with:
name: test-results
path: |
reports/mypy_junit.xml
reports/junit.xml
reports/coverage.xml
reports/coverage.md
reports/coverage_html
oe_python_template_example.log
retention-days: 30
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: helmut-hoffer-von-ankershoffen/oe-python-template-example
- name: Upload test results to Codecov
if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: SonarQube Scan
if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
uses: SonarSource/sonarqube-scan-action@0303d6b62e310685c0e34d0b9cde218036885c4d # v5.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}