Skip to content

Commit

Permalink
feat: Experimental taskwarrior caching
Browse files Browse the repository at this point in the history
  • Loading branch information
RedEtherbloom committed Nov 13, 2024
1 parent 3775bfb commit 826a303
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 18 deletions.
85 changes: 77 additions & 8 deletions .github/actions/install-taskwarrior/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# WARNING: This composite may override the rust toolchain version.
# Please set your rust toolchain version after this action ran just to be sure(until this was tested),
name: 'Install Taskwarrior'
description: 'Builds taskwarrior from the latest stable release and installs it'
inputs:
Expand All @@ -7,17 +9,84 @@ inputs:
runs:
using: "composite"
steps:
# TODO: Format onto two lines
- name: Clone latest stable taskwarrior release
- name: Download latest stable taskwarrior release
# This pattern should only match match assets with a [numbers and dots] suffix
run: gh release download -p "task-[0-9.]*.tar.gz" -R "GothenburgBitFactory/taskwarrior" -D /tmp/download
shell: bash
env:
GH_TOKEN: ${{ inputs.secret_gh_token }}
# Future proofing
- name: Check that we only got one release asset
run: |
if [ $(ls -1 /tmp/download | wc -l) -ne 1 ]
then
echo "Expected exactly one release asset"
exit 1
else
echo "Got expected number of release assets"
fi
shell: bash
- name: Move taskwarrior source to task.tar.gz
run: |
cd /tmp/download
find . -name "*.tar.gz" -exec mv {} task.tar.gz \;
shell: bash
- name: Calculate SHA256 of task.tar.gz source(version cache check)
id: calculate-task-sha256
run: echo "task_sha256=$(/usr/bin/sha256sum /tmp/download/task.tar.gz)" >> $GITHUB_OUTPUT
shell: bash
- name: Restore cached taskwarrior build
id: cache-taskwarrior-restore
uses: actions/cache/restore@v4
with:
path: |
~/.local/bin/task
~/.local/share/doc/task/*
~/.local/share/man/man1/task.1
~/.local/share/man/man5/task-color.5
~/.local/share/man/man5/task-sync.5
~/.local/share/man/man5/taskrc.5
~/.local/share/zsh/site-functions/_task
key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}
- name: Extract taskwarrior source code
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: |
cd /tmp/download
tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;'
cd /tmp
git clone --depth 1 --recurse-submodules --shallow-submodules --single-branch -b stable git@github:com/GothenburgBitFactory/taskwarrior.git taskwarrior
mv download/task taskwarrior
rm -rf download
shell: bash
- name: Install rust toolchain
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- name: Setup rust cache for taskchampion
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
- name: Compile and install taskwarrior
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
run: |
cd /tmp/taskwarrior
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release .
cmake --build build
sudo cmake --install build
cd ..
rm -rf taskwarrior/
shell: bash
cmake --build build -j $(nproc)
cmake --install build
cd
rm -rf /tmp/taskwarrior/
shell: bash
- name: Cache taskwarrior build result
id: cache-taskwarrior-save
uses: actions/cache/save@v4
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
with:
path: |
~/.local/bin/task
~/.local/share/doc/task/*
~/.local/share/man/man1/task.1
~/.local/share/man/man5/task-color.5
~/.local/share/man/man5/task-sync.5
~/.local/share/man/man5/taskrc.5
~/.local/share/zsh/site-functions/_task
key: ${{ steps.cache-taskwarrior-restore.outputs.cache-primary-key }}
12 changes: 6 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,6 @@ jobs:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- name: Install toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- run: sudo apt-get update
- name: 'Install Taskwarrior'
uses: ./.github/actions/install-taskwarrior
Expand All @@ -217,6 +211,12 @@ jobs:
- run: |
# prepare taskwarrior, initial setup
task rc.confirmation=off || echo 0
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- name: Clean environment for grcov
uses: clechasseur/rs-cargo@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jobs:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- run: sudo apt-get update
- name: 'Install Taskwarrior'
uses: ./.github/actions/install-taskwarrior
Expand All @@ -43,6 +39,10 @@ jobs:
- run: |
# prepare taskwarrior, initial setup
task rc.confirmation=off || echo 0
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- uses: clechasseur/rs-cargo@v2
with:
command: test
Expand Down

0 comments on commit 826a303

Please sign in to comment.