mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-10 00:23:03 +02:00
ci: Refactor timelord action to use git-warp-time fallback
Updates the timelord action to fall back to git-warp-time when the cache is completely empty, enabling timestamp restoration even on fresh builds. Simplifies the interface by making inputs optional with sensible defaults and adds Docker integration via buildkit-cache-dance.
This commit is contained in:
parent
5d3e10a048
commit
90baadd032
3 changed files with 62 additions and 34 deletions
|
@ -1,46 +1,68 @@
|
||||||
name: timelord
|
name: timelord
|
||||||
description: |
|
description: |
|
||||||
Use timelord to set file timestamps
|
Use timelord to set file timestamps with git-warp-time fallback for cache misses
|
||||||
inputs:
|
inputs:
|
||||||
key:
|
key:
|
||||||
description: |
|
description: |
|
||||||
The key to use for caching the timelord data.
|
The key to use for caching the timelord data.
|
||||||
This should be unique to the repository and the runner.
|
required: false
|
||||||
required: true
|
default: ''
|
||||||
default: timelord-v0
|
|
||||||
path:
|
path:
|
||||||
description: |
|
description: |
|
||||||
The path to the directory to be timestamped.
|
The path to the directory to be timestamped.
|
||||||
This should be the root of the repository.
|
required: false
|
||||||
required: true
|
default: ''
|
||||||
default: .
|
|
||||||
|
outputs:
|
||||||
|
database-path:
|
||||||
|
description: Path to timelord database
|
||||||
|
value: '${{ env.TIMELORD_CACHE_PATH }}'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Cache timelord-cli installation
|
- name: Set defaults
|
||||||
id: cache-timelord-bin
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: ~/.cargo/bin/timelord
|
|
||||||
key: timelord-cli-v3.0.1
|
|
||||||
- name: Install timelord-cli
|
|
||||||
uses: https://github.com/cargo-bins/cargo-binstall@main
|
|
||||||
if: steps.cache-timelord-bin.outputs.cache-hit != 'true'
|
|
||||||
- run: cargo binstall timelord-cli@3.0.1
|
|
||||||
shell: bash
|
shell: bash
|
||||||
if: steps.cache-timelord-bin.outputs.cache-hit != 'true'
|
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
|
||||||
|
|
||||||
- name: Load timelord files
|
- name: Install timelord-cli and git-warp-time
|
||||||
uses: actions/cache/restore@v3
|
uses: https://github.com/taiki-e/install-action@v2
|
||||||
with:
|
with:
|
||||||
path: /timelord/
|
tool: git-warp-time,timelord-cli@3.0.1
|
||||||
key: ${{ inputs.key }}
|
|
||||||
- name: Run timelord to set timestamps
|
- 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'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: timelord sync --source-dir ${{ inputs.path }} --cache-dir /timelord/
|
run: |
|
||||||
- name: Save timelord
|
echo "Complete timelord cache miss - running git-warp-time"
|
||||||
uses: actions/cache/save@v3
|
git fetch --unshallow
|
||||||
|
if [ "${{ env.TIMELORD_PATH }}" = "." ]; then
|
||||||
|
~/.cargo/bin/git-warp-time --quiet
|
||||||
|
else
|
||||||
|
~/.cargo/bin/git-warp-time --quiet ${{ env.TIMELORD_PATH }}
|
||||||
|
fi
|
||||||
|
echo "Git timestamps restored"
|
||||||
|
|
||||||
|
- name: Run timelord sync
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
|
~/.cargo/bin/timelord sync --source-dir ${{ env.TIMELORD_PATH }} --cache-dir ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
|
|
||||||
|
- name: Save updated timelord cache immediately
|
||||||
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
path: /timelord/
|
path: ${{ env.TIMELORD_CACHE_PATH }}
|
||||||
key: ${{ inputs.key }}
|
key: ${{ env.TIMELORD_KEY }}
|
||||||
|
|
|
@ -150,10 +150,7 @@ jobs:
|
||||||
echo "Commit timestamp: $timestamp"
|
echo "Commit timestamp: $timestamp"
|
||||||
|
|
||||||
- uses: ./.forgejo/actions/timelord
|
- uses: ./.forgejo/actions/timelord
|
||||||
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
id: timelord
|
||||||
with:
|
|
||||||
key: timelord-v0
|
|
||||||
path: .
|
|
||||||
|
|
||||||
- name: Cache Rust registry
|
- name: Cache Rust registry
|
||||||
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
||||||
|
@ -190,7 +187,6 @@ jobs:
|
||||||
var-lib-apt-${{ matrix.slug }}
|
var-lib-apt-${{ matrix.slug }}
|
||||||
key: var-lib-apt-${{ matrix.slug }}
|
key: var-lib-apt-${{ matrix.slug }}
|
||||||
- name: inject cache into docker
|
- name: inject cache into docker
|
||||||
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
|
|
||||||
uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3.3.0
|
uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3.3.0
|
||||||
with:
|
with:
|
||||||
cache-map: |
|
cache-map: |
|
||||||
|
@ -202,7 +198,8 @@ jobs:
|
||||||
"id": "cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }}"
|
"id": "cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }}"
|
||||||
},
|
},
|
||||||
"var-cache-apt-${{ matrix.slug }}": "/var/cache/apt",
|
"var-cache-apt-${{ matrix.slug }}": "/var/cache/apt",
|
||||||
"var-lib-apt-${{ matrix.slug }}": "/var/lib/apt"
|
"var-lib-apt-${{ matrix.slug }}": "/var/lib/apt",
|
||||||
|
"${{ steps.timelord.outputs.database-path }}": "/root/.cache/timelord"
|
||||||
}
|
}
|
||||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ RUN <<EOF
|
||||||
curl --retry 5 -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
curl --retry 5 -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||||
cargo binstall --no-confirm cargo-sbom --version $CARGO_SBOM_VERSION
|
cargo binstall --no-confirm cargo-sbom --version $CARGO_SBOM_VERSION
|
||||||
cargo binstall --no-confirm lddtree --version $LDDTREE_VERSION
|
cargo binstall --no-confirm lddtree --version $LDDTREE_VERSION
|
||||||
|
cargo binstall --no-confirm timelord-cli@3.0.1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Set up xx (cross-compilation scripts)
|
# Set up xx (cross-compilation scripts)
|
||||||
|
@ -133,6 +134,14 @@ FROM toolchain AS builder
|
||||||
# Get source
|
# Get source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Restore timestamps from timelord cache if available
|
||||||
|
RUN if [ -f /root/.cache/timelord/timelord.db ]; then \
|
||||||
|
echo "Restoring timestamps from timelord cache"; \
|
||||||
|
timelord sync --source-dir /app --cache-dir /root/.cache/timelord; \
|
||||||
|
else \
|
||||||
|
echo "No timelord cache found, timestamps will be build time"; \
|
||||||
|
fi
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
# Verify environment configuration
|
# Verify environment configuration
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue