Skip to content

Commit f6e4751

Browse files
committed
Disallow toolstate regression at the last week of the 6-week cycle.
1 parent e181050 commit f6e4751

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/ci/docker/x86_64-gnu-tools/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
COPY scripts/sccache.sh /scripts/
1818
RUN sh /scripts/sccache.sh
1919

20+
COPY x86_64-gnu-tools/checkregression.py /tmp/
2021
COPY x86_64-gnu-tools/checktools.sh /tmp/
2122
COPY x86_64-gnu-tools/repo.sh /tmp/
2223

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2018 The Rust Project Developers. See the COPYRIGHT
5+
# file at the top-level directory of this distribution and at
6+
# http://rust-lang.org/COPYRIGHT.
7+
#
8+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
11+
# option. This file may not be copied, modified, or distributed
12+
# except according to those terms.
13+
14+
import sys
15+
import json
16+
17+
if __name__ == '__main__':
18+
os_name = sys.argv[1]
19+
toolstate_file = sys.argv[2]
20+
current_state = sys.argv[3]
21+
22+
with open(toolstate_file, 'r') as f:
23+
toolstate = json.load(f)
24+
with open(current_state, 'r') as f:
25+
current = json.load(f)
26+
27+
regressed = False
28+
for cur in current:
29+
tool = cur['tool']
30+
state = cur[os_name]
31+
new_state = toolstate.get(tool, '')
32+
if new_state < state:
33+
print(
34+
'Error: The state of "{}" has regressed from "{}" to "{}"'
35+
.format(tool, state, new_state)
36+
)
37+
regressed = True
38+
39+
if regressed:
40+
sys.exit(1)

src/ci/docker/x86_64-gnu-tools/checktools.sh

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ TOOLSTATE_FILE="$(realpath $2)"
1717
OS="$3"
1818
COMMIT="$(git rev-parse HEAD)"
1919
CHANGED_FILES="$(git diff --name-status HEAD HEAD^)"
20+
SIX_WEEK_CYCLE="$(( ($(date +%s) / 604800 - 3) % 6 ))"
21+
# ^ 1970 Jan 1st is a Thursday, and our release dates are also on Thursdays,
22+
# thus we could divide by 604800 (7 days in seconds) directly.
2023

2124
touch "$TOOLSTATE_FILE"
2225

@@ -59,6 +62,11 @@ if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_s
5962
sed -i "1 a\\
6063
$COMMIT\t$(cat "$TOOLSTATE_FILE")
6164
" "history/$OS.tsv"
65+
# if we are at the last week in the 6-week release cycle, reject any kind of regression.
66+
if [ $SIX_WEEK_CYCLE -eq 5 ]; then
67+
python2.7 "$(dirname $0)/checkregression.py" \
68+
"$OS" "$TOOLSTATE_FILE" "rust-toolstate/_data/latest.json"
69+
fi
6270
rm -f "$MESSAGE_FILE"
6371
exit 0
6472
fi

0 commit comments

Comments
 (0)