Skip to content

Commit db4c9b2

Browse files
authored
Add index.html into artifacts, unify upload to s3 (#6754)
1 parent 6302faa commit db4c9b2

File tree

4 files changed

+527
-61
lines changed

4 files changed

+527
-61
lines changed

.github/actions/test_ya/action.yml

Lines changed: 51 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,38 @@ runs:
7676
mkdir -p $TMP_DIR
7777
echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
7878
79-
export LOG_DIR=$TMP_DIR/logs
80-
echo "LOG_DIR=$LOG_DIR" >> $GITHUB_ENV
81-
mkdir -p $LOG_DIR
79+
# The whole dir will be uploaded to s3 with public (=wild internet) ACL
80+
export PUBLIC_DIR=$TMP_DIR/results
81+
echo "PUBLIC_DIR=$PUBLIC_DIR" >> $GITHUB_ENV
82+
mkdir -p $PUBLIC_DIR
8283
83-
export OUT_DIR=$TMP_DIR/out
84-
echo "OUT_DIR=$OUT_DIR" >> $GITHUB_ENV
85-
mkdir -p $OUT_DIR
84+
export YA_MAKE_OUT_DIR=$TMP_DIR/out
85+
echo "YA_MAKE_OUT_DIR=$YA_MAKE_OUT_DIR" >> $GITHUB_ENV
86+
mkdir -p $YA_MAKE_OUT_DIR
8687
87-
export ARTIFACTS_DIR=$TMP_DIR/artifacts
88+
export ARTIFACTS_DIR=$PUBLIC_DIR/artifacts
8889
echo "ARTIFACTS_DIR=$ARTIFACTS_DIR" >> $GITHUB_ENV
90+
echo "ARTIFACTS_DIR_URL=$S3_URL_PREFIX/artifacts" >> $GITHUB_ENV
8991
mkdir -p $ARTIFACTS_DIR
9092
91-
export TEST_ARTIFACTS_DIR=$TMP_DIR/test_artifacts
93+
export TEST_ARTIFACTS_DIR=$PUBLIC_DIR/test_artifacts
9294
echo "TEST_ARTIFACTS_DIR=$TEST_ARTIFACTS_DIR" >> $GITHUB_ENV
95+
echo "TEST_ARTIFACTS_DIR_URL=$S3_URL_PREFIX/test_artifacts" >> $GITHUB_ENV
9396
mkdir -p $TEST_ARTIFACTS_DIR
9497
95-
export REPORTS_ARTIFACTS_DIR=$TMP_DIR/artifacts/test_reports
96-
echo "REPORTS_ARTIFACTS_DIR=$REPORTS_ARTIFACTS_DIR" >> $GITHUB_ENV
97-
mkdir -p $REPORTS_ARTIFACTS_DIR
9898
99-
export JUNIT_REPORT_PARTS=$TMP_DIR/junit-split
100-
echo "JUNIT_REPORT_PARTS=$JUNIT_REPORT_PARTS" >> $GITHUB_ENV
101-
mkdir -p $JUNIT_REPORT_PARTS
102-
103-
echo "JUNIT_REPORT_XML=$TMP_DIR/junit.xml" >> $GITHUB_ENV
99+
echo "JUNIT_REPORT_XML=$PUBLIC_DIR/junit.xml" >> $GITHUB_ENV
104100
echo "TESTMO_URL=${{ inputs.testman_url }}" >> $GITHUB_ENV
105-
echo "SUMMARY_LINKS=$(mktemp)" >> $GITHUB_ENV
101+
echo "SUMMARY_LINKS=$PUBLIC_DIR/summary_links.txt" >> $GITHUB_ENV
106102
echo "BUILD_PRESET=${{ inputs.build_preset }}" >> $GITHUB_ENV
107103
108-
echo "YA_TEST_LOG_FILENAME=$LOG_DIR/ya_test.log" >> $GITHUB_ENV
109-
echo "YA_TEST_LOG_URL=$S3_URL_PREFIX/test_logs/ya_test.log" >> $GITHUB_ENV
110-
echo "S3_LOG_BUCKET_PATH=$S3_BUCKET_PATH/test_logs" >> $GITHUB_ENV
104+
echo "YA_TEST_LOG=$PUBLIC_DIR/ya_log.log" >> $GITHUB_ENV
105+
echo "YA_TEST_LOG_URL=$S3_URL_PREFIX/ya_log.log" >> $GITHUB_ENV
111106
112-
export log_url="$S3_URL_PREFIX/build_logs/ya_make.log"
113-
echo "LOG_URL=$log_url" >> $GITHUB_ENV
114-
echo "log_url=$log_url" >> $GITHUB_OUTPUT
107+
108+
echo YA_MAKE_OUTPUT="$PUBLIC_DIR/ya_make_output.log" >> $GITHUB_ENV
109+
export YA_MAKE_OUTPUT_URL="$S3_URL_PREFIX/ya_make_output.log"
110+
echo "YA_MAKE_OUTPUT_URL=$YA_MAKE_OUTPUT_URL" >> $GITHUB_ENV
115111
116112
# install test mo
117113
npm install -g @testmo/testmo-cli
@@ -270,14 +266,14 @@ runs:
270266
echo "Build+Tests **{platform_name}-${BUILD_PRESET}** is running..." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
271267
set +ex
272268
(./ya make ${{ inputs.build_target }} "${params[@]}" \
273-
--stat --log-file "$YA_TEST_LOG_FILENAME" -DCONSISTENT_DEBUG \
269+
--stat --log-file "$YA_TEST_LOG" -DCONSISTENT_DEBUG \
274270
--no-dir-outputs --test-failure-code 0 --build-all \
275-
--cache-size 2TB --force-build-depends --evlog-file "$TMP_DIR/ya_evlog.jsonl" \
276-
--junit "$JUNIT_REPORT_XML" --output "$OUT_DIR"; echo $? > exit_code) |& tee $TMP_DIR/ya_make.log
277-
set -ex
271+
--cache-size 2TB --force-build-depends --evlog-file "$PUBLIC_DIR/ya_evlog.jsonl" \
272+
--junit "$JUNIT_REPORT_XML" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& tee $YA_MAKE_OUTPUT
273+
set -e
278274
RC=`cat exit_code`
279275
280-
echo "10 [Ya make output]($LOG_URL)" >> $SUMMARY_LINKS
276+
echo "10 [Ya make output]($YA_MAKE_OUTPUT_URL)" >> $SUMMARY_LINKS
281277
echo "20 [Ya logs]($YA_TEST_LOG_URL)" >> $SUMMARY_LINKS
282278
283279
if [ $RC -ne 0 ]; then
@@ -300,7 +296,7 @@ runs:
300296
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
301297
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
302298
-d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
303-
echo "Build failed. see the [logs]($LOG_URL)." | .github/scripts/tests/comment-pr.py --fail
299+
echo "Build failed. see the [logs]($YA_MAKE_OUTPUT_URL)." | .github/scripts/tests/comment-pr.py --fail
304300
else
305301
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
306302
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
@@ -314,22 +310,18 @@ runs:
314310
run: |
315311
set -x
316312
# archive unitest reports (orig)
317-
gzip -c $JUNIT_REPORT_XML > $REPORTS_ARTIFACTS_DIR/orig_junit.xml.gz
313+
gzip -c $JUNIT_REPORT_XML > $PUBLIC_DIR/orig_junit.xml.gz
318314
319315
# postprocess junit report
320316
.github/scripts/tests/transform-ya-junit.py -i \
321317
-m .github/config/muted_ya.txt \
322-
--ya-out "$OUT_DIR" \
323-
--log-url-prefix "$S3_URL_PREFIX/logs/" \
318+
--ya-out "$YA_MAKE_OUT_DIR" \
319+
--log-url-prefix "$ARTIFACTS_DIR_URL/logs/" \
324320
--log-out-dir "$ARTIFACTS_DIR/logs/" \
325321
--test-stuff-out "$TEST_ARTIFACTS_DIR/" \
326-
--test-stuff-prefix "$S3_TEST_ARTIFACTS_URL_PREFIX/" \
322+
--test-stuff-prefix "$TEST_ARTIFACTS_DIR_URL/" \
327323
"$JUNIT_REPORT_XML"
328-
329-
.github/scripts/tests/split-junit.py -o "$JUNIT_REPORT_PARTS" "$JUNIT_REPORT_XML"
330-
331-
# archive unitest reports (transformed)
332-
tar -C $JUNIT_REPORT_PARTS/.. -czf $REPORTS_ARTIFACTS_DIR/junit_parts.xml.tar.gz $(basename $JUNIT_REPORT_PARTS)
324+
333325

334326
- name: Test history upload results to YDB
335327
if: inputs.run_tests
@@ -360,6 +352,14 @@ runs:
360352
TESTMO_TOKEN: ${{ inputs.testman_token }}
361353
run: |
362354
set -x
355+
356+
# split large junit_report
357+
export JUNIT_REPORT_PARTS=$TMP_DIR/junit-split
358+
mkdir -p $JUNIT_REPORT_PARTS
359+
.github/scripts/tests/split-junit.py -o "$JUNIT_REPORT_PARTS" "$JUNIT_REPORT_XML"
360+
# archive unitest reports (transformed)
361+
tar -C $JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $JUNIT_REPORT_PARTS)
362+
363363
PROXY_ADDR=127.0.0.1:8888
364364
365365
openssl req -x509 -newkey rsa:2048 \
@@ -388,16 +388,6 @@ runs:
388388
TESTMO_TOKEN: ${{ inputs.testman_token }}
389389
run: |
390390
testmo automation:run:complete --instance "$TESTMO_URL" --run-id ${{ steps.th.outputs.runid }}
391-
392-
- name: sync logs results to s3
393-
if: always()
394-
shell: bash
395-
run: |
396-
set -x
397-
echo "::group::s3-sync"
398-
s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$LOG_DIR/" "$S3_LOG_BUCKET_PATH/"
399-
s3cmd sync --acl-public --no-progress --stats --no-check-md5 "$TMP_DIR/ya_make.log" "$S3_BUCKET_PATH/build_logs/"
400-
echo "::endgroup::"
401391
402392
- name: analyze tests results
403393
shell: bash
@@ -414,12 +404,10 @@ runs:
414404
fi
415405
416406
mkdir $ARTIFACTS_DIR/summary/
417-
418-
cat $SUMMARY_LINKS | python3 -c 'import sys; print(" | ".join([v for _, v in sorted([l.strip().split(" ", 1) for l in sys.stdin], key=lambda a: (int(a[0]), a))]))' >> $GITHUB_STEP_SUMMARY
419407
420408
.github/scripts/tests/generate-summary.py \
421409
--summary-out-path $ARTIFACTS_DIR/summary/ \
422-
--summary-url-prefix $S3_URL_PREFIX/summary/ \
410+
--summary-url-prefix $ARTIFACTS_DIR_URL/summary/ \
423411
--test-history-url "$TEST_HISTORY_URL" \
424412
--test-log-url="$YA_TEST_LOG_URL" \
425413
--build-preset "$BUILD_PRESET" \
@@ -439,23 +427,25 @@ runs:
439427
if [[ $teststatus != "success" ]];then
440428
echo "status=failed" >> $GITHUB_OUTPUT
441429
fi
442-
443-
- name: sync test results to s3
444-
if: always() && inputs.run_tests
445-
shell: bash
446-
run: |
447-
set -x
448-
echo "::group::s3-sync"
449-
s3cmd sync -r --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$ARTIFACTS_DIR/" "$S3_BUCKET_PATH/"
450-
s3cmd sync -r --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$TEST_ARTIFACTS_DIR/" "$S3_TEST_ARTIFACTS_BUCKET_PATH/"
451-
echo "::endgroup::"
452430
453431
- name: check test results
454432
if: inputs.run_tests
455433
shell: bash
456434
run: |
457435
.github/scripts/tests/fail-checker.py "$JUNIT_REPORT_XML"
458436
437+
- name: sync results to s3 and publish links
438+
if: always()
439+
shell: bash
440+
run: |
441+
set -x
442+
echo "::group::s3-sync"
443+
.github/scripts/Indexer/indexer.py -r "$PUBLIC_DIR/"
444+
echo "00 [Workflow run results](${S3_URL_PREFIX}/index.html)" >> $SUMMARY_LINKS
445+
s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
446+
cat $SUMMARY_LINKS | python3 -c 'import sys; print(" | ".join([v for _, v in sorted([l.strip().split(" ", 1) for l in sys.stdin], key=lambda a: (int(a[0]), a))]))' >> $GITHUB_STEP_SUMMARY
447+
echo "::endgroup::"
448+
459449
- name: show free space
460450
if: always()
461451
shell: bash

.github/scripts/Indexer/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Josh Brunty
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

.github/scripts/Indexer/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Indexer
2+
Indexer is a Python script that generates an .html index of files within a selected directory. You can start from the current directory or from folder passed as first positional argument. Optionally filter by file types with --filter "\*.py". This script is an hodgepodge of older scripts [collected](https://stackoverflow.com/questions/10961378/how-to-generate-an-html-directory-list-using-python) & built over the years.
3+
4+
* Blog Post: https://joshbrunty.github.io/2021/10/29/indexer.html
5+
* Video Tutorial (YouTube): https://youtu.be/-1_gVP3NtPo
6+
7+
## Prerequisites:
8+
* This script requires you to have **[Python > 3.x.x](https://www.python.org/downloads/)** installed on your system.
9+
* Ideally use the current build of **[Python 3.10](https://www.python.org/downloads/release/python-3100/)** (significantly faster processing on larger directories! 🏃)
10+
11+
## Usage
12+
```python3 indexer.py /top_dir```
13+
14+
## Positional arguments:
15+
* ```top_dir```: top folder from which to start generating indexes (*uses current working directory/folder if not specified*).
16+
17+
## Optional arguments:
18+
* ```-h, --help```: show help message (along with available options)
19+
* ```-f, --filter```: only include files matching [glob](https://docs.python.org/3/library/glob.html) (i.e.```indexer.py --filter '\**/*.jpg'*```).
20+
* ```-o filename, --output-file filename```: Custom output file (by default generates "index.html")
21+
* ```-r, --recursive```: recursively process nested folders/directories (*Off/False by default*).
22+
* ```-v, --verbose```: verbosely list every processed file. (*NOTE: will take longer time with complex file tree structures on slow terminals.*)
23+
24+
## Features:
25+
* File Size & Modified Time display for each file.
26+
* Create a custom output file (*by default *index.html* is generated*).
27+
* Ability to match/filter specified parameters using [glob](https://docs.python.org/3/library/glob.html) (*'\**/*.jpg' & '\**/*.UFD'*).
28+
29+
## Contact
30+
* Email: josh [dot] brunty [at] marshall [dot] edu
31+
* Follow @joshbrunty on Twitter [![Twitter Follow](https://img.shields.io/twitter/follow/shields_io.svg?style=social&label=Follow&maxAge=25920)](https://twitter.com/joshbrunty)
32+
* Indexer is Open Source via the MIT License (MIT): <a href="https://opensource.org/licenses/MIT" rel="nofollow">
33+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="SysScout is Open Source via MIT License">
34+
</a>

0 commit comments

Comments
 (0)