From 6057070cfd6deb16f65f625c4c6a7c9ee32bf9f4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 20 Apr 2020 18:19:33 -0700 Subject: [PATCH] ;ci: push: restore timestamps to fix unnecessary recompilation https://www.reddit.com/r/haskell/comments/g00ldn/haskell_stack_on_github_actions --- .github/workflows/push.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c4cd892d2..0b8ab78f2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -26,6 +26,21 @@ jobs: - name: Check out uses: actions/checkout@v2 + # Fetch all history, rather than a shallow clone, so that we + # can restore timestamps (see below). + with: + fetch-depth: 0 + + # Restore timestamps to help stack not rebuild unchanged files. + # https://stackoverflow.com/questions/60906336 + # https://stackoverflow.com/a/36243002/84401 + # https://www.reddit.com/r/haskell/comments/g00ldn/haskell_stack_on_github_actions/ + - name: Restore source file timestamps + run: | + git ls-tree -r --name-only HEAD | while read filename; do + TS="$(git log -1 --format="%ct" -- ${filename})" + touch "${filename}" -mt "$(date --date="@$TS" "+%Y%m%d%H%M.%S")" + done # cached things