Skip to content

Commit 3957592

Browse files
committed
Move tailing log file to post test in test lifecycle
1 parent fd2fe1e commit 3957592

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

circle.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ test:
1818
override:
1919
- 'chmod +x ./tools/ci/circle/script && ./tools/ci/circle/script':
2020
parallel: true
21+
post:
22+
- 'chmod +x ./tools/ci/circle/after_script && ./tools/ci/circle/after_script':
23+
parallel: true

tools/ci/circle/after_script

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build script to run at the end of the Circle CI test [lifecycle][1].
4+
#
5+
# [1]: https://circleci.com/docs/configuration/#test
6+
7+
8+
# VARIABLES #
9+
10+
# Define a file containing log output:
11+
log_file='/var/log/circle-ci.log'
12+
13+
# Define the number of lines of logged output to print:
14+
tail_num_lines=5000
15+
16+
17+
# FUNCTIONS #
18+
19+
# Defines an error handler.
20+
on_error() {
21+
echo 'ERROR: An error was encountered during execution.' >&2
22+
exit 1
23+
}
24+
25+
# Tails a log file.
26+
#
27+
# $1 - log file to tail
28+
# $2 - number of lines to tail
29+
tail_output() {
30+
echo "Printing the last $2 lines of log output..." >&2
31+
tail -"$2" "$1"
32+
}
33+
34+
# Main execution sequence.
35+
main() {
36+
tail_output "${log_file}" "${tail_num_lines}"
37+
}
38+
39+
# Set an error handler:
40+
trap 'on_error' ERR
41+
42+
# Run main:
43+
main

tools/ci/circle/script

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ heartbeat_interval='30s'
5959
# Declare a variable for storing the heartbeat process id:
6060
heartbeat_pid=""
6161

62-
# Define the number of lines of logged output to print upon completion:
63-
tail_num_lines=4000
64-
6562

6663
# FUNCTIONS #
6764

@@ -76,7 +73,6 @@ on_error() {
7673

7774
# Runs clean-up tasks.
7875
cleanup() {
79-
tail_output "${log_file}" "${tail_num_lines}"
8076
stop_heartbeat
8177
}
8278

@@ -110,15 +106,6 @@ stop_heartbeat() {
110106
kill "${heartbeat_pid}"
111107
}
112108

113-
# Tails a log file.
114-
#
115-
# $1 - log file to tail
116-
# $2 - number of lines to tail
117-
tail_output() {
118-
echo "Printing the last $2 lines of log output..." >&2
119-
tail -"$2" "$1"
120-
}
121-
122109
# Creates a directory.
123110
#
124111
# $1 - directory path

0 commit comments

Comments
 (0)