2025-05-11 20:34:22 +01:00
|
|
|
name: timelord
|
|
|
|
|
description: |
|
2025-09-08 04:32:23 +01:00
|
|
|
Use timelord to set file timestamps with git-warp-time fallback for cache misses
|
2025-05-11 20:34:22 +01:00
|
|
|
inputs:
|
|
|
|
|
key:
|
|
|
|
|
description: |
|
|
|
|
|
The key to use for caching the timelord data.
|
2025-09-08 04:32:23 +01:00
|
|
|
required: false
|
|
|
|
|
default: ''
|
2025-05-11 20:34:22 +01:00
|
|
|
path:
|
|
|
|
|
description: |
|
|
|
|
|
The path to the directory to be timestamped.
|
2025-09-08 04:32:23 +01:00
|
|
|
required: false
|
|
|
|
|
default: ''
|
|
|
|
|
|
|
|
|
|
outputs:
|
|
|
|
|
database-path:
|
|
|
|
|
description: Path to timelord database
|
|
|
|
|
value: '${{ env.TIMELORD_CACHE_PATH }}'
|
2025-05-11 20:34:22 +01:00
|
|
|
|
|
|
|
|
runs:
|
|
|
|
|
using: composite
|
|
|
|
|
steps:
|
2025-09-08 04:32:23 +01:00
|
|
|
- name: Set defaults
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
echo "TIMELORD_KEY=${{ inputs.key || format('timelord-v1-{0}-{1}', github.repository, hashFiles('**/*.rs', '**/Cargo.toml', '**/Cargo.lock')) }}" >> $GITHUB_ENV
|
|
|
|
|
echo "TIMELORD_PATH=${{ inputs.path || '.' }}" >> $GITHUB_ENV
|
|
|
|
|
echo "TIMELORD_CACHE_PATH=$HOME/.cache/timelord" >> $GITHUB_ENV
|
2025-09-13 16:17:28 +01:00
|
|
|
echo "PATH=/usr/share/rust/.cargo/bin:$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
|
2025-09-08 04:32:23 +01:00
|
|
|
|
|
|
|
|
- name: Restore binary cache
|
|
|
|
|
id: binary-cache
|
|
|
|
|
uses: actions/cache/restore@v4
|
2025-05-11 20:34:22 +01:00
|
|
|
with:
|
2025-09-13 16:17:28 +01:00
|
|
|
path: |
|
|
|
|
|
/usr/share/rust/.cargo/bin
|
|
|
|
|
~/.cargo/bin
|
|
|
|
|
key: timelord-binaries-v2
|
2025-09-08 04:32:23 +01:00
|
|
|
|
|
|
|
|
- name: Check if binaries need installation
|
2025-05-11 20:34:22 +01:00
|
|
|
shell: bash
|
2025-09-08 04:32:23 +01:00
|
|
|
id: check-binaries
|
|
|
|
|
run: |
|
|
|
|
|
NEED_INSTALL=false
|
2025-09-13 16:17:28 +01:00
|
|
|
if [ ! -e /usr/share/rust/.cargo/bin/timelord ] && [ ! -e ~/.cargo/bin/timelord ]; then
|
|
|
|
|
echo "timelord-cli not found in /usr/share/rust/.cargo/bin or ~/.cargo/bin, needs installation"
|
2025-09-08 04:32:23 +01:00
|
|
|
NEED_INSTALL=true
|
|
|
|
|
fi
|
2025-09-13 16:17:28 +01:00
|
|
|
if [ ! -e /usr/share/rust/.cargo/bin/git-warp-time ] && [ ! -e ~/.cargo/bin/git-warp-time ]; then
|
|
|
|
|
echo "git-warp-time not found in /usr/share/rust/.cargo/bin or ~/.cargo/bin, needs installation"
|
2025-09-08 04:32:23 +01:00
|
|
|
NEED_INSTALL=true
|
|
|
|
|
fi
|
|
|
|
|
echo "need-install=$NEED_INSTALL" >> $GITHUB_OUTPUT
|
2025-05-11 20:34:22 +01:00
|
|
|
|
2025-09-08 04:32:23 +01:00
|
|
|
- name: Install timelord-cli and git-warp-time
|
|
|
|
|
if: steps.check-binaries.outputs.need-install == 'true'
|
|
|
|
|
uses: https://github.com/taiki-e/install-action@v2
|
2025-05-11 20:34:22 +01:00
|
|
|
with:
|
2025-09-08 04:32:23 +01:00
|
|
|
tool: git-warp-time,timelord-cli@3.0.1
|
|
|
|
|
|
|
|
|
|
- name: Save binary cache
|
|
|
|
|
if: steps.check-binaries.outputs.need-install == 'true'
|
|
|
|
|
uses: actions/cache/save@v4
|
|
|
|
|
with:
|
2025-09-13 16:17:28 +01:00
|
|
|
path: |
|
|
|
|
|
/usr/share/rust/.cargo/bin
|
|
|
|
|
~/.cargo/bin
|
|
|
|
|
key: timelord-binaries-v2
|
2025-09-08 04:32:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Restore timelord cache with fallbacks
|
|
|
|
|
id: timelord-restore
|
|
|
|
|
uses: actions/cache/restore@v4
|
|
|
|
|
with:
|
|
|
|
|
path: ${{ env.TIMELORD_CACHE_PATH }}
|
|
|
|
|
key: ${{ env.TIMELORD_KEY }}
|
|
|
|
|
restore-keys: |
|
|
|
|
|
timelord-v1-${{ github.repository }}-
|
|
|
|
|
|
|
|
|
|
- name: Initialize timestamps on complete cache miss
|
|
|
|
|
if: steps.timelord-restore.outputs.cache-hit != 'true'
|
2025-05-11 20:34:22 +01:00
|
|
|
shell: bash
|
2025-09-08 04:32:23 +01:00
|
|
|
run: |
|
|
|
|
|
echo "Complete timelord cache miss - running git-warp-time"
|
|
|
|
|
git fetch --unshallow
|
|
|
|
|
if [ "${{ env.TIMELORD_PATH }}" = "." ]; then
|
2025-09-13 16:17:28 +01:00
|
|
|
git-warp-time --quiet
|
2025-09-08 04:32:23 +01:00
|
|
|
else
|
2025-09-13 16:17:28 +01:00
|
|
|
git-warp-time --quiet ${{ env.TIMELORD_PATH }}
|
2025-09-08 04:32:23 +01:00
|
|
|
fi
|
|
|
|
|
echo "Git timestamps restored"
|
|
|
|
|
|
|
|
|
|
- name: Run timelord sync
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
mkdir -p ${{ env.TIMELORD_CACHE_PATH }}
|
2025-09-13 16:17:28 +01:00
|
|
|
timelord sync --source-dir ${{ env.TIMELORD_PATH }} --cache-dir ${{ env.TIMELORD_CACHE_PATH }}
|
2025-09-08 04:32:23 +01:00
|
|
|
|
|
|
|
|
- name: Save updated timelord cache immediately
|
|
|
|
|
uses: actions/cache/save@v4
|
2025-05-11 20:34:22 +01:00
|
|
|
with:
|
2025-09-08 04:32:23 +01:00
|
|
|
path: ${{ env.TIMELORD_CACHE_PATH }}
|
|
|
|
|
key: ${{ env.TIMELORD_KEY }}
|