mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 23:46:41 +02:00
feat: Cache taskwarrior compilation
This commit is contained in:
parent
873424e5ef
commit
5d77f74448
3 changed files with 92 additions and 34 deletions
106
.github/actions/install-taskwarrior/action.yml
vendored
106
.github/actions/install-taskwarrior/action.yml
vendored
|
@ -1,45 +1,103 @@
|
||||||
|
# This action definition may look complicated, but it only builds taskwarrior from the latest source release and installs it.
|
||||||
|
# The rest of the file is caching of results and checks to avoid ambiguous failure in case taskwarrior changes their release strategy.
|
||||||
name: 'Install Taskwarrior'
|
name: 'Install Taskwarrior'
|
||||||
description: 'Builds taskwarrior from the latest stable release and installs it'
|
description: 'Builds latests stable taskwarrior release install it'
|
||||||
inputs:
|
inputs:
|
||||||
secret_gh_token:
|
secret_gh_token:
|
||||||
description: "GH token for downloading the assets"
|
description: "GH token used for downloading the release asset"
|
||||||
required: true
|
required: true
|
||||||
|
rust_toolchain:
|
||||||
|
description: "Rust toolchain to compile taskwarrior with"
|
||||||
|
default: stable
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
# This pattern should only match match assets with a [numbers and dots] suffix
|
- name: Update apt
|
||||||
- name: Download latest stable taskwarrior release
|
run: sudo apt get update
|
||||||
run: |
|
|
||||||
gh release download -p "task-[0-9.]*.tar.gz" -R "GothenburgBitFactory/taskwarrior" -D /tmp/download
|
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
- name: Install libuuid
|
||||||
|
run: sudo apt-get install uuid-dev uuid-runtime
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Download latest stable taskwarrior source release
|
||||||
|
# This pattern only matches assets with a [numbers and dots] version suffix
|
||||||
|
run: gh release download --repo "GothenburgBitFactory/taskwarrior" --pattern "task-[0-9.]*.tar.gz" --dir /tmp/download
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
GH_TOKEN: ${{ inputs.secret_gh_token }}
|
GH_TOKEN: ${{ inputs.secret_gh_token }}
|
||||||
# Future proofing
|
- name: Ensure that we only got one release asset
|
||||||
- name: Check that we only got one release asset
|
|
||||||
run: |
|
run: |
|
||||||
if [ $(ls -1 /tmp/download | wc -l) -ne 1 ]
|
number_of_assets=$(ls -1 /tmp/download | wc -l)
|
||||||
then
|
if [ $number_of_assets -ne 1 ]
|
||||||
echo "Expected exactly one release asset"
|
then
|
||||||
|
echo "Expected exactly one release asset, got $number_of_assets instead"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Got expected number of release assets"
|
echo "Got expected number of release assets"
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Extract taskwarrior without version number
|
- name: Move taskwarrior source to task.tar.gz
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/download
|
cd /tmp/download
|
||||||
find . -name "*.tar.gz" -exec mv {} task.tar.gz \;
|
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 | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
- name: Restore cached taskwarrior build
|
||||||
|
id: cache-taskwarrior-restore
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/task.deb
|
||||||
|
key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}
|
||||||
|
|
||||||
|
- name: Install rust toolchain and rust cache
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: inputs.rust_toolchain
|
||||||
|
override: false
|
||||||
|
- name: Extract taskwarrior source code
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
cd /tmp/download
|
||||||
|
# Remove the version suffix from extracted directory
|
||||||
tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;'
|
tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;'
|
||||||
cd /tmp
|
cd /tmp
|
||||||
mv download/task taskwarrior
|
mv download/task taskwarrior
|
||||||
rm -rf download
|
rm -rf download
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Compile taskwarrior
|
- name: Set selected rust toolchain as default for taskwarrior
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
|
run: rustup override set ${{ inputs.rust_toolchain }} --path /tmp/taskwarrior
|
||||||
|
shell: bash
|
||||||
|
- name: Compile and install taskwarrior
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/taskwarrior
|
cd /tmp/taskwarrior
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release .
|
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release .
|
||||||
cmake --build build
|
cmake --build build -j $(nproc)
|
||||||
sudo cmake --install build
|
cd build
|
||||||
cd ..
|
# Create a stub debian package. WARNING: This package has no dependencies set
|
||||||
rm -rf taskwarrior/
|
cpack -D CPACK_PACKAGE_CONTACT="stub" -D CPACK_PACKAGE_FILE_NAME="task" -G DEB
|
||||||
shell: bash
|
mv task.deb /tmp
|
||||||
|
cd /tmp
|
||||||
|
rm -rf /tmp/taskwarrior/
|
||||||
|
shell: bash
|
||||||
|
- name: Unset rust toolchain again
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
|
run: rustup override unset --path /tmp/taskwarrior
|
||||||
|
shell: bash
|
||||||
|
- name: Cache taskwarrior build result
|
||||||
|
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||||
|
id: cache-taskwarrior-save
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/task.deb
|
||||||
|
key: ${{ steps.cache-taskwarrior-restore.outputs.cache-primary-key }}
|
||||||
|
|
||||||
|
- name: Install taskwarrior
|
||||||
|
run: sudo dpkg -i /tmp/task.deb
|
||||||
|
shell: bash
|
||||||
|
|
12
.github/workflows/cd.yml
vendored
12
.github/workflows/cd.yml
vendored
|
@ -197,12 +197,6 @@ jobs:
|
||||||
RUST_BACKTRACE: full
|
RUST_BACKTRACE: full
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- run: sudo apt-get update
|
||||||
- name: 'Install Taskwarrior'
|
- name: 'Install Taskwarrior'
|
||||||
uses: ./.github/actions/install-taskwarrior
|
uses: ./.github/actions/install-taskwarrior
|
||||||
|
@ -217,6 +211,12 @@ jobs:
|
||||||
- run: |
|
- run: |
|
||||||
# prepare taskwarrior, initial setup
|
# prepare taskwarrior, initial setup
|
||||||
task rc.confirmation=off || echo 0
|
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
|
- name: Clean environment for grcov
|
||||||
uses: clechasseur/rs-cargo@v2
|
uses: clechasseur/rs-cargo@v2
|
||||||
with:
|
with:
|
||||||
|
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -25,10 +25,6 @@ jobs:
|
||||||
RUST_BACKTRACE: full
|
RUST_BACKTRACE: full
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- name: 'Install Taskwarrior'
|
- name: 'Install Taskwarrior'
|
||||||
uses: ./.github/actions/install-taskwarrior
|
uses: ./.github/actions/install-taskwarrior
|
||||||
|
@ -43,6 +39,10 @@ jobs:
|
||||||
- run: |
|
- run: |
|
||||||
# prepare taskwarrior, initial setup
|
# prepare taskwarrior, initial setup
|
||||||
task rc.confirmation=off || echo 0
|
task rc.confirmation=off || echo 0
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
- uses: clechasseur/rs-cargo@v2
|
- uses: clechasseur/rs-cargo@v2
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue