-
-
Notifications
You must be signed in to change notification settings - Fork 170
207 lines (189 loc) · 6.97 KB
/
Copy pathdocs.yml
File metadata and controls
207 lines (189 loc) · 6.97 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
---
name: Documentation and public code coverage
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
tests: ${{ steps.filter.outputs.tests }}
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v7.0.0
with:
persist-credentials: false
- uses: dorny/paths-filter@v4.0.1
id: filter
with:
base: main
filters: |
src:
- "src/**"
- "**.cpp"
- "**.h"
- "**.hpp"
- "**.ui"
- "**.qrc"
- "**.pro"
- "**.pri"
tests:
- "tests/**"
docs:
- "docs/**"
docs:
needs: changes
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check if docs needed
id: need_docs
shell: bash
run: |
if [[ "${NEEDS_CHANGES_OUTPUTS_SRC}" == "true" ]] || \
[[ "${NEEDS_CHANGES_OUTPUTS_TESTS}" == "true" ]] || \
[[ "${NEEDS_CHANGES_OUTPUTS_DOCS}" == "true" ]] || \
[[ "${{ github.event_name }}" == "merge_group" ]]; then
echo "run_docs=true" >> "$GITHUB_OUTPUT"
else
echo "run_docs=false" >> "$GITHUB_OUTPUT"
fi
env:
NEEDS_CHANGES_OUTPUTS_SRC: ${{ needs.changes.outputs.src }}
NEEDS_CHANGES_OUTPUTS_TESTS: ${{ needs.changes.outputs.tests }}
NEEDS_CHANGES_OUTPUTS_DOCS: ${{ needs.changes.outputs.docs }}
- name: No changes - skipping
if: steps.need_docs.outputs.run_docs != 'true'
run: echo "No relevant changes - skipping docs and coverage"
- uses: actions/checkout@v7.0.0
if: steps.need_docs.outputs.run_docs == 'true'
with:
persist-credentials: false
- name: Install Qt
if: steps.need_docs.outputs.run_docs == 'true'
uses: jurplel/install-qt-action@v4.3.1
- name: Install Doxygen
if: steps.need_docs.outputs.run_docs == 'true'
run: |
# Pinned Doxygen release. doxygen.nl has intermittent outages, so try
# the identical GitHub release asset (CDN-backed) first and fall back
# to doxygen.nl, retrying each source before giving up.
DOXYGEN_VERSION=1.17.0
tarball="doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
github_tag="Release_${DOXYGEN_VERSION//./_}"
urls=(
"https://github.com/doxygen/doxygen/releases/download/${github_tag}/${tarball}"
"https://doxygen.nl/files/${tarball}"
)
downloaded=0
for url in "${urls[@]}"; do
echo "Fetching Doxygen from ${url}"
if curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors \
"${url}" -o doxygen.tar.gz; then
downloaded=1
break
fi
echo "::warning::Failed to download Doxygen from ${url}"
done
if [ "${downloaded}" -ne 1 ]; then
echo "::error::Could not download Doxygen ${DOXYGEN_VERSION}"
exit 1
fi
tar -xzf doxygen.tar.gz
sudo cp -r "doxygen-${DOXYGEN_VERSION}/bin/"* /usr/local/bin/
rm -rf doxygen.tar.gz "doxygen-${DOXYGEN_VERSION}"
# Install graphviz via apt
sudo apt-get update && sudo apt-get install -y graphviz
- name: Extract version
if: steps.need_docs.outputs.run_docs == 'true'
run: |
VERSION=$(grep -E '^VERSION *=' qtpass.pri | cut -d'=' -f2 | tr -d ' ')
if [ -z "$VERSION" ]; then
echo "Error: Failed to extract VERSION from qtpass.pri" >&2
exit 1
fi
echo "QTPASS_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Extracted version: $VERSION"
TMPFILE=$(mktemp)
if [ -z "$TMPFILE" ]; then
echo "Error: Failed to create temporary file." >&2
exit 1
fi
if ! sed "s|^PROJECT_NUMBER.*=.*|PROJECT_NUMBER = $VERSION|" Doxyfile > "$TMPFILE"; then
echo "Error: Failed to update PROJECT_NUMBER in Doxyfile." >&2
rm -f "$TMPFILE"
exit 1
fi
if ! grep -qF -- "PROJECT_NUMBER = $VERSION" "$TMPFILE"; then
echo "Error: PROJECT_NUMBER was not updated in Doxyfile." >&2
rm -f "$TMPFILE"
exit 1
fi
if ! mv "$TMPFILE" Doxyfile; then
echo "Error: Failed to replace Doxyfile with updated content." >&2
rm -f "$TMPFILE"
exit 1
fi
echo "Updated Doxyfile with version: $VERSION"
- name: Generate documentation
if: steps.need_docs.outputs.run_docs == 'true'
run: doxygen
- name: Install lcov
if: steps.need_docs.outputs.run_docs == 'true'
run: sudo apt-get update && sudo apt-get install -y lcov
- name: qmake
if: steps.need_docs.outputs.run_docs == 'true'
run: qmake CONFIG+=coverage
- name: Build
if: steps.need_docs.outputs.run_docs == 'true'
run: make
- name: Run tests and generate coverage
if: steps.need_docs.outputs.run_docs == 'true'
run: |
make lcov TESTARGS="--platform offscreen -o qtpass.junit.xml,junitxml"
- name: Upload coverage to Codecov
if: steps.need_docs.outputs.run_docs == 'true' && !cancelled()
uses: codecov/codecov-action@v7.0.0
with:
files: ./docs/coverage/.lcov.total
flags: qtpass
name: qtpass-lcov
fail_ci_if_error: false
verbose: true
use_pypi: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: steps.need_docs.outputs.run_docs == 'true' && !cancelled()
uses: codecov/codecov-action@v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "tests/auto/*/qtpass.junit.xml"
report_type: test_results
use_pypi: true
fail_ci_if_error: true
- name: Upload coverage to Coveralls
if: steps.need_docs.outputs.run_docs == 'true' && !cancelled()
uses: coverallsapp/github-action@v2.3.7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ./docs/coverage/.lcov.total
format: lcov
fail-on-error: false
- name: Deploy to GitHub Pages
if: steps.need_docs.outputs.run_docs == 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./docs
destination_dir: docs
keep_files: true
user_name: "GitHub Actions"
user_email: "github-actions[bot]@users.noreply.github.com"