Skip to content

Commit 2596afe

Browse files
authored
Rollup merge of rust-lang#41075 - aidanhs:aphs-enable-appveyor-cache, r=alexcrichton
Re-enable appveyor cache After breaking the queue last time, I'm cautiously back with a PR to re-enable caching on appveyor. If you look at https://ci.appveyor.com/project/rust-lang/rust/build/1.0.2623/job/46o90by4ari6gege (one of the multiple runs that started failed, there are actually two errors - one for restoring the cache, one right at the bottom for creating a directory. I only noticed the restore error at the time as I was a bit rushed to revert and didn't stop to wonder why it continued - turns out appveyor [does not abort on cache restore failure](appveyor/ci#723). Turns out the cause of the build failures was the cache directory existing and me being thinking that because mkdir on windows is [recursive by default](http://stackoverflow.com/a/905239/2352259), it ignores the error if the directory already exists. Apparently this is not true, so now it checks if the directory exists before attempting to create. In addition, I've added some more paranoia to double check everything is sane.
2 parents 02a7e4c + b970bc2 commit 2596afe

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Diff for: appveyor.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,18 @@ install:
141141
- set SCCACHE_ERROR_LOG=%CD%/sccache.log
142142

143143
test_script:
144-
- appveyor-retry sh -c 'git submodule deinit -f . && git submodule update --init'
144+
- if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc
145+
- sh src/ci/init_repo.sh . /c/cache/rustsrc
145146
- set SRC=.
146147
- set NO_CCACHE=1
147148
- sh src/ci/run.sh
148149

149150
on_failure:
150-
- cat %CD%/sccache.log
151+
- cat %CD%\sccache.log
152+
- cat C:\Users\appveyor\AppData\Local\Temp\1\build-cache-logs\*.log
151153

152154
cache:
155+
- C:\cache\rustsrc
153156
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
154157
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
155158
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"

Diff for: src/ci/init_repo.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ fi
3838

3939
# Wipe the cache if it's not valid, or mark it as invalid while we update it
4040
if [ ! -f "$cache_valid_file" ]; then
41-
rm -rf "$CACHE_DIR" && mkdir "$CACHE_DIR"
41+
rm -rf "$CACHE_DIR"
42+
mkdir "$CACHE_DIR"
4243
else
43-
rm "$cache_valid_file"
44+
stat_lines=$(cd "$cache_src_dir" && git status --porcelain | wc -l)
45+
stat_ec=$(cd "$cache_src_dir" && git status >/dev/null 2>&1 && echo $?)
46+
if [ ! -d "$cache_src_dir/.git" -o $stat_lines != 0 -o $stat_ec != 0 ]; then
47+
# Something is badly wrong - the cache valid file is here, but something
48+
# about the git repo is fishy. Nuke it all, just in case
49+
echo "WARNING: $cache_valid_file exists but bad repo: l:$stat_lines, ec:$stat_ec"
50+
rm -rf "$CACHE_DIR"
51+
mkdir "$CACHE_DIR"
52+
else
53+
rm "$cache_valid_file"
54+
fi
4455
fi
4556

4657
# Update the cache (a pristine copy of the rust source master)

0 commit comments

Comments
 (0)