diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index adcdd41f1..fea07d254 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -58,6 +58,20 @@ jobs: - name: Check out uses: actions/checkout@v2 + # deep clone so 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 # things to be cached/restored: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index c974b5474..cfa13fa21 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -30,6 +30,20 @@ jobs: - name: Check out uses: actions/checkout@v2 + # deep clone so 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 # things to be cached/restored: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ed73f6476..55ec294d6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -29,8 +29,7 @@ jobs: - name: Check out uses: actions/checkout@v2 - # Fetch all history, rather than a shallow clone, so that we - # can restore timestamps (see below). + # deep clone so we can restore timestamps (see below) with: fetch-depth: 0 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 28ac93ed4..552c748db 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -31,6 +31,20 @@ jobs: - name: Check out uses: actions/checkout@v2 + # deep clone so 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 # things to be cached/restored: