forked from eclipse-score/reference_integration
-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (199 loc) · 8.37 KB
/
test_and_docs.yml
File metadata and controls
204 lines (199 loc) · 8.37 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
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
name: Code Quality & Documentation
permissions:
contents: write
pages: write
pull-requests: write
id-token: write
on:
pull_request_target: # Allows forks to trigger the docs build
types: [opened, reopened, synchronize]
push:
branches:
- main
merge_group:
types: [checks_requested]
release:
types: [created]
# Do not flood CI with unneeded previous runs in PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: ${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test_and_docs:
runs-on: ubuntu-22.04
permissions:
contents: write # required to upload release assets
pull-requests: write
steps:
- name: Clean disk space
uses: eclipse-score/more-disk-space@v1
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
cache-save: ${{ github.event_name == 'push' }}
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install lcov
run: |
sudo apt-get update
sudo apt-get install -y lcov
- name: Checkout repository (pull_request_target via workflow_call)
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Checkout repository
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v4
- name: Execute Unit Tests with Coverage Analysis
run: |
python ./scripts/quality_runners.py
- name: Execute Feature Integration Tests
run: |
bazel test //feature_integration_tests/test_cases:fit
- name: Publish build summary
if: always()
run: |
if [ -f docs/verification/unit_test_summary.md ]; then
cat docs/verification/unit_test_summary.md >> "$GITHUB_STEP_SUMMARY"
else
echo "No build summary file found (docs/verification/unit_test_summary.md)" >> "$GITHUB_STEP_SUMMARY"
fi
echo "" >> "$GITHUB_STEP_SUMMARY" # Add a newline for better formatting
if [ -f docs/verification/coverage_summary.md ]; then
cat docs/verification/coverage_summary.md >> "$GITHUB_STEP_SUMMARY"
else
echo "No coverage summary file found (docs/verification/coverage_summary.md)" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Create archive of test reports
if: github.ref_type == 'tag'
run: |
mkdir -p artifacts
find bazel-testlogs/external -name 'test.xml' -print0 | xargs -0 -I{} cp --parents {} artifacts/
cp -r "$(bazel info --lockfile_mode=error bazel-bin)/coverage/rust-tests" artifacts/rust
zip -r ${{ github.event.repository.name }}_test_reports.zip artifacts/
shell: bash
- name: Upload release asset (attach ZIP to GitHub Release)
uses: softprops/action-gh-release@v2.5.0
if: github.ref_type == 'tag'
with:
files: ${{ github.event.repository.name }}_test_reports.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Graphviz
uses: eclipse-score/apt-install@main
with:
packages: graphviz
cache: false
- name: Build documentation
run: |
bazel --output_base="/home/runner/.cache/bazel/output_base" run \
--lockfile_mode=error \
--repo_contents_cache="/home/runner/.cache/bazel/repo_contents" \
--repository_cache="/home/runner/.cache/bazel/repo" \
--disk_cache="/home/runner/.cache/bazel/disk" \
//:docs_combo_experimental -- \
--github_user=${{ github.repository_owner }} \
--github_repo=${{ github.event.repository.name }}
CURRENT=$(realpath .)
bazel run //scripts/tooling -- misc html_report --output ${CURRENT}/_build/status_dashboard.html
tar -cf github-pages.tar _build
- name: Upload documentation artifact
uses: actions/upload-artifact@v4.4.0
with:
name: github-pages-${{ github.event.pull_request.head.sha || github.sha }}
path: github-pages.tar
retention-days: 3
if-no-files-found: error
docs-deploy:
name: Deploy Documentation to GitHub Pages
runs-on: ${{ vars.REPO_RUNNER_LABELS && fromJSON(vars.REPO_RUNNER_LABELS) || 'ubuntu-latest' }}
needs: test_and_docs
permissions:
pages: write
id-token: write
contents: write
pull-requests: write
steps:
- name: Ensure gh-pages branch exists with initial files
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
set -e
if ! git ls-remote --exit-code --heads "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" gh-pages; then
echo "gh-pages branch does not exist. Creating it..."
git clone --depth=1 "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" repo
cd repo
git fetch origin main --depth=1
AUTHOR_NAME=$(git log origin/main -1 --pretty=format:'%an')
AUTHOR_EMAIL=$(git log origin/main -1 --pretty=format:'%ae')
git config user.name "$AUTHOR_NAME"
git config user.email "$AUTHOR_EMAIL"
echo "Using commit identity: $AUTHOR_NAME <$AUTHOR_EMAIL>"
git checkout --orphan gh-pages
git rm -rf . || true
REPO_NAME=$(basename "${REPO}")
OWNER_NAME="${REPO%%/*}"
touch versions.json
echo "[" > versions.json
echo " {" >> versions.json
echo " \"version\": \"main\"," >> versions.json
echo " \"url\": \"https://${OWNER_NAME}.github.io/${REPO_NAME}/main/\"" >> versions.json
echo " }" >> versions.json
echo "]" >> versions.json
touch index.html
echo '<!DOCTYPE html>' > index.html
echo '<html lang="en">' >> index.html
echo '<head>' >> index.html
echo ' <meta charset="UTF-8">' >> index.html
echo ' <meta http-equiv="refresh" content="0; URL=main/">' >> index.html
echo ' <title>Redirecting...</title>' >> index.html
echo '</head>' >> index.html
echo '<body>' >> index.html
echo ' <p>If you are not redirected, <a href="main/">click here</a>.</p>' >> index.html
echo '</body>' >> index.html
echo '</html>' >> index.html
touch .nojekyll
git add versions.json index.html .nojekyll
git commit -m "Initialize gh-pages branch with versions.json and index.html"
git push origin gh-pages
cd ..
rm -rf repo
else
echo "gh-pages branch exists. Skipping creation."
fi
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Download documentation artifact
uses: actions/download-artifact@v4.1.8
with:
name: github-pages-${{ github.event.pull_request.head.sha || github.sha }}
- name: Untar documentation artifact
run: mkdir -p extracted_docs && tar -xf github-pages.tar -C extracted_docs
- name: Deploy 🚀
id: pages-deployment
uses: eclipse-score/cicd-workflows/.github/actions/deploy-versioned-pages@main
with:
source_folder: extracted_docs/_build
deployment_type: workflow