From 92418bd9f4859ac96a659817387f8aabf899bbcb Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Mon, 4 Nov 2024 18:35:17 +0100 Subject: [PATCH 1/9] fix: Update the upload-artifacts due to deprecation of v2 See https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/ for details. v1 and v2 have been deprecated since 30.06.2024. modified: .github/workflows/build.yml modified: .github/workflows/cd.yml --- .github/workflows/build.yml | 2 +- .github/workflows/cd.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de2469d1..bd3d2cee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,7 +80,7 @@ jobs: shasum -a 256 taskwarrior-tui-${{ matrix.target }}.tar.gz > taskwarrior-tui-${{ matrix.target }}.sha256 fi - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: taskwarrior-tui path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 01a34539..ec729d0b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -91,7 +91,7 @@ jobs: shasum -a 256 taskwarrior-tui-${{ matrix.target }}.tar.gz > taskwarrior-tui-${{ matrix.target }}.sha256 fi - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: taskwarrior-tui path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz @@ -131,7 +131,7 @@ jobs: - name: Build deb package run: cargo deb -p taskwarrior-tui -o target/debian/taskwarrior-tui.deb - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: taskwarrior-tui path: target/debian/taskwarrior-tui.deb @@ -161,7 +161,7 @@ jobs: - name: Build rpm package run: cargo rpm build - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: taskwarrior-tui path: target/release/rpmbuild/RPMS/x86_64/taskwarrior-tui-*.x86_64.rpm From 39792b229950b32a44c54dac373e31aaad369b62 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Mon, 11 Nov 2024 22:26:47 +0100 Subject: [PATCH 2/9] feat: Build taskwarrior CI against stable --- .../actions/install-taskwarrior/action.yml | 45 +++++++++++++++++++ .github/workflows/cd.yml | 13 ++---- .github/workflows/ci.yml | 13 ++---- 3 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 .github/actions/install-taskwarrior/action.yml diff --git a/.github/actions/install-taskwarrior/action.yml b/.github/actions/install-taskwarrior/action.yml new file mode 100644 index 00000000..7a540d56 --- /dev/null +++ b/.github/actions/install-taskwarrior/action.yml @@ -0,0 +1,45 @@ +name: 'Install Taskwarrior' +description: 'Builds taskwarrior from the latest stable release and installs it' +inputs: + secret_gh_token: + description: "GH token for downloading the assets" + required: true +runs: + using: "composite" + steps: + # This pattern should only match match assets with a [numbers and dots] suffix + - name: Download latest stable taskwarrior release + 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: Extract taskwarrior without version number + run: | + cd /tmp/download + find . -name "*.tar.gz" -exec mv {} task.tar.gz \; + tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;' + cd /tmp + mv download/task taskwarrior + rm -rf download + shell: bash + - name: Compile taskwarrior + 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 \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ec729d0b..386a4d3a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -204,15 +204,10 @@ jobs: override: true profile: minimal - run: sudo apt-get update - - name: Compile taskwarrior - run: | - cd /tmp - git clone https://github.com/GothenburgBitFactory/taskwarrior - cd taskwarrior - git checkout v3.0.0 - cmake -DCMAKE_BUILD_TYPE=release -DENABLE_SYNC=OFF . - make - sudo make install + - name: 'Install Taskwarrior' + uses: ./.github/actions/install-taskwarrior + with: + secret_gh_token: ${{ secrets.GITHUB_TOKEN }} - run: | task --version - uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee66e1e0..de360a26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,15 +32,10 @@ jobs: toolchain: stable override: true - run: sudo apt-get update - - name: Compile taskwarrior - run: | - cd /tmp - git clone https://github.com/GothenburgBitFactory/taskwarrior - cd taskwarrior - git checkout v3.0.0 - cmake -DCMAKE_BUILD_TYPE=release -DENABLE_SYNC=OFF . - make - sudo make install + - name: 'Install Taskwarrior' + uses: ./.github/actions/install-taskwarrior + with: + secret_gh_token: ${{ secrets.GITHUB_TOKEN }} - run: | task --version - uses: actions/checkout@v4 From 0ab679accaa21dd12c791ac347eb7eaaab048db4 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Mon, 11 Nov 2024 22:36:28 +0100 Subject: [PATCH 3/9] fix: Append target for unique artifact names --- .github/workflows/build.yml | 2 +- .github/workflows/cd.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd3d2cee..6fb416f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,7 +82,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: taskwarrior-tui + name: taskwarrior-tui-${{ matrix.target }} path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz - name: Releasing assets if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 386a4d3a..dc82b159 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -93,7 +93,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: taskwarrior-tui + name: taskwarrior-tui-${{ matrix.target }} path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz - name: Releasing assets if: startsWith(github.ref, 'refs/tags/') @@ -133,7 +133,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: taskwarrior-tui + name: taskwarrior-tui-deb path: target/debian/taskwarrior-tui.deb - name: Releasing assets if: startsWith(github.ref, 'refs/tags/') @@ -163,7 +163,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: taskwarrior-tui + name: taskwarrior-tui-rpm path: target/release/rpmbuild/RPMS/x86_64/taskwarrior-tui-*.x86_64.rpm - name: Releasing assets if: startsWith(github.ref, 'refs/tags/') From a4b221fe75916f2ea6bd5467659753e9cbd7ea75 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Mon, 11 Nov 2024 23:53:49 +0100 Subject: [PATCH 4/9] fix: Disable broken MacOS compression --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fb416f3..48ad2faa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,6 +69,8 @@ jobs: file: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} args: ${{ matrix.upx_args }} strip: ${{ matrix.strip }} + # MacOS Compression disabled due to bug https://github.com/upx/upx/blob/44e4bd0b5454ff8aee1ff3376974dfe6014300d9/NEWS#L31 + if: ${{ matrix.os != 'macOS-latest' }} - name: Packaging binary shell: bash run: | From 4bd7e34d827d386b53850b4b93a63d08e74b94c4 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Tue, 12 Nov 2024 03:01:11 +0100 Subject: [PATCH 5/9] refactor: Modernize CI/CD components action-rs has been disabled since last year. Additionally, Zprofile got recently deprecated. --- .github/workflows/build.yml | 6 ++-- .github/workflows/cd.yml | 60 ++++++++++++++++++++----------------- .github/workflows/ci.yml | 26 +++++++--------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 48ad2faa..3f02296b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,12 +54,12 @@ jobs: MACOSX_DEPLOYMENT_TARGET: 10.7 steps: - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} - default: true - - uses: actions-rs/cargo@v1 + override: true + - uses: clechasseur/rs-cargo@v2 with: command: build args: --release ${{matrix.features}} --target=${{ matrix.target }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index dc82b159..2c8eb5ae 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -64,12 +64,12 @@ jobs: MACOSX_DEPLOYMENT_TARGET: 10.7 steps: - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} - default: true - - uses: actions-rs/cargo@v1 + override: true + - uses: clechasseur/rs-cargo@v2 with: command: build args: --release ${{matrix.features}} --target=${{ matrix.target }} @@ -122,7 +122,7 @@ jobs: steps: - name: Check out Git repository uses: actions/checkout@v4 - - uses: actions-rs/cargo@v1 + - uses: clechasseur/rs-cargo@v2 with: command: build args: --release @@ -150,7 +150,7 @@ jobs: steps: - name: Check out Git repository uses: actions/checkout@v4 - - uses: actions-rs/cargo@v1 + - uses: clechasseur/rs-cargo@v2 with: command: build args: --release @@ -180,7 +180,7 @@ jobs: steps: - name: Check out Git repository uses: actions/checkout@v4 - - uses: actions-rs/cargo@v1 + - uses: clechasseur/rs-cargo@v2 with: command: build args: --release @@ -198,11 +198,11 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: nightly override: true - profile: minimal + components: llvm-tools-preview - run: sudo apt-get update - name: 'Install Taskwarrior' uses: ./.github/actions/install-taskwarrior @@ -217,36 +217,40 @@ jobs: - run: | # prepare taskwarrior, initial setup task rc.confirmation=off || echo 0 - - name: Execute tests - uses: actions-rs/cargo@v1 + - name: Clean environment for grcov + uses: clechasseur/rs-cargo@v2 + with: + command: clean + - name: Build taskwarrior-tui with coverage + uses: clechasseur/rs-cargo@v2 + with: + command: build + env: + RUSTFLAGS: "-Cinstrument-coverage" + - name: Run taskwarrior-tui tests in coverage environment + uses: clechasseur/rs-cargo@v2 with: command: test - args: --all + args: --worksoace env: - CARGO_INCREMENTAL: 0 - RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests" - - # Note that `actions-rs/grcov` Action can install `grcov` too, - # but can't use faster installation methods yet. - # As a temporary experiment `actions-rs/install` Action plugged in here. - # Consider **NOT** to copy that into your workflow, - # but use `actions-rs/grcov` only - - name: Pre-installing grcov - uses: actions-rs/install@v0.1 + RUSTFLAGS: "-Cinstrument-coverage" + LLVM_PROFILE_FILE: "your_name-%p-%m.profraw" + - name: Install grcov + uses: clechasseur/rs-cargo@v2 with: - crate: grcov - use-tool-cache: true - + command: install + args: grcov - name: Gather coverage data - id: coverage - uses: actions-rs/grcov@v0.1 - + run: | + mkdir ./target/debug/coverage/ + grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/ + shell: bash - name: Coveralls upload uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel: true - path-to-lcov: ${{ steps.coverage.outputs.report }} + file: ./target/debug/coverage/lcov grcov_finalize: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de360a26..1293a51d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable override: true - - uses: actions-rs/cargo@v1 + - uses: clechasseur/rs-cargo@v2 with: command: check @@ -26,9 +25,8 @@ jobs: RUST_BACKTRACE: full steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable override: true - run: sudo apt-get update @@ -45,23 +43,22 @@ jobs: - run: | # prepare taskwarrior, initial setup task rc.confirmation=off || echo 0 - - uses: actions-rs/cargo@v1 + - uses: clechasseur/rs-cargo@v2 with: command: test - args: --all -- --nocapture + args: --workspace -- --nocapture fmt: name: Rustfmt runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: nightly override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 + components: rustfmt + - uses: clechasseur/rs-cargo@v2 with: command: fmt args: --all -- --check @@ -71,13 +68,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 + components: clippy + - uses: clechasseur/rs-cargo@v2 with: command: clippy args: -- -D warnings From d9ab17156bae6c797754821f205f04ab90e97f7c Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Wed, 13 Nov 2024 03:10:45 +0100 Subject: [PATCH 6/9] feat: Cache taskwarrior compilation --- .../actions/install-taskwarrior/action.yml | 106 ++++++++++++++---- .github/workflows/cd.yml | 12 +- .github/workflows/ci.yml | 8 +- 3 files changed, 92 insertions(+), 34 deletions(-) diff --git a/.github/actions/install-taskwarrior/action.yml b/.github/actions/install-taskwarrior/action.yml index 7a540d56..67d663a3 100644 --- a/.github/actions/install-taskwarrior/action.yml +++ b/.github/actions/install-taskwarrior/action.yml @@ -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' -description: 'Builds taskwarrior from the latest stable release and installs it' +description: 'Builds latests stable taskwarrior release install it' inputs: - secret_gh_token: - description: "GH token for downloading the assets" + secret_gh_token: + description: "GH token used for downloading the release asset" required: true + rust_toolchain: + description: "Rust toolchain to compile taskwarrior with" + default: stable runs: using: "composite" steps: - # This pattern should only match match assets with a [numbers and dots] suffix - - name: Download latest stable taskwarrior release - run: | - gh release download -p "task-[0-9.]*.tar.gz" -R "GothenburgBitFactory/taskwarrior" -D /tmp/download + - name: Update apt + run: sudo apt get update + shell: bash + - name: Install libuuid + run: sudo apt-get install uuid-dev uuid-runtime shell: bash - env: + + - 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 }} - # Future proofing - - name: Check that we only got one release asset + - name: Ensure that we only got one release asset run: | - if [ $(ls -1 /tmp/download | wc -l) -ne 1 ] - then - echo "Expected exactly one release asset" + number_of_assets=$(ls -1 /tmp/download | wc -l) + if [ $number_of_assets -ne 1 ] + then + echo "Expected exactly one release asset, got $number_of_assets instead" exit 1 else - echo "Got expected number of release assets" + echo "Got expected number of release assets" fi - shell: bash - - name: Extract taskwarrior without version number + 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 | 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 - find . -name "*.tar.gz" -exec mv {} task.tar.gz \; + # Remove the version suffix from extracted directory tar -xf task.tar.gz --transform='s;^task-[0-9.]*/;task/;' cd /tmp mv download/task taskwarrior rm -rf download - shell: bash - - name: Compile taskwarrior + shell: bash + - 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: | cd /tmp/taskwarrior cmake -S . -B build -DCMAKE_BUILD_TYPE=Release . - cmake --build build - sudo cmake --install build - cd .. - rm -rf taskwarrior/ - shell: bash \ No newline at end of file + cmake --build build -j $(nproc) + cd build + # Create a stub debian package. WARNING: This package has no dependencies set + cpack -D CPACK_PACKAGE_CONTACT="stub" -D CPACK_PACKAGE_FILE_NAME="task" -G DEB + 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 diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2c8eb5ae..b4749dc0 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 @@ -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: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1293a51d..23728a6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 From b05539b3ab3f500f6aaaab9127f54094b8e988c0 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Wed, 13 Nov 2024 16:24:43 +0100 Subject: [PATCH 7/9] refactor: Merge build workflows --- .github/workflows/build.yml | 9 ++-- .github/workflows/cd.yml | 95 +------------------------------------ 2 files changed, 6 insertions(+), 98 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f02296b..020bb8c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: Build -on: [pull_request] +on: + pull_request: + workflow_call: jobs: build: runs-on: ${{ matrix.os }} @@ -11,9 +13,6 @@ jobs: target: x86_64-apple-darwin rust_flags: '' features: '' - binary_postfix: '' - upx_args: --best - strip: true - os: ubuntu-latest target: x86_64-unknown-linux-gnu rust_flags: '' @@ -66,7 +65,7 @@ jobs: - name: Compress binaries uses: svenstaro/upx-action@v2 with: - file: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} + files: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} args: ${{ matrix.upx_args }} strip: ${{ matrix.strip }} # MacOS Compression disabled due to bug https://github.com/upx/upx/blob/44e4bd0b5454ff8aee1ff3376974dfe6014300d9/NEWS#L31 diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b4749dc0..cbe506e8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,99 +11,8 @@ permissions: contents: write jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: macOS-latest - target: x86_64-apple-darwin - rust_flags: "" - features: "" - binary_postfix: "" - upx_args: --best - strip: true - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - rust_flags: "" - features: "" - binary_postfix: "" - upx_args: --best --lzma - strip: true - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - rust_flags: "" - features: "" - binary: "taskwarrior-tui-x86_64-unknown-linux-musl" - upx_args: --best --lzma - strip: true - - os: windows-latest - target: x86_64-pc-windows-gnu - rust_flags: -C target-feature=+crt-static - features: "" - binary_postfix: ".exe" - upx_args: -9 - strip: false - - os: windows-latest - target: x86_64-pc-windows-msvc - rust_flags: -C target-feature=+crt-static - features: "" - binary_postfix: ".exe" - upx_args: -9 - strip: false - - os: windows-latest - target: i686-pc-windows-msvc - rust_flags: -C target-feature=+crt-static - features: "" - binary_postfix: ".exe" - upx_args: -9 - strip: false - env: - RUSTFLAGS: ${{ matrix.rust_flags }} - MACOSX_DEPLOYMENT_TARGET: 10.7 - steps: - - uses: actions/checkout@master - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - target: ${{ matrix.target }} - override: true - - uses: clechasseur/rs-cargo@v2 - with: - command: build - args: --release ${{matrix.features}} --target=${{ matrix.target }} - - name: Compress binaries - uses: svenstaro/upx-action@v2 - with: - files: | - target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} - args: ${{ matrix.upx_args }} - strip: ${{ matrix.strip }} - - name: Packaging binary - shell: bash - run: | - cd target/${{ matrix.target }}/release - tar czvf taskwarrior-tui-${{ matrix.target }}.tar.gz taskwarrior-tui${{ matrix.binary_postfix }} - if [[ ${{ runner.os }} == 'Windows' ]]; then - certutil -hashfile taskwarrior-tui-${{ matrix.target }}.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > taskwarrior-tui-${{ matrix.target }}.sha256 - else - shasum -a 256 taskwarrior-tui-${{ matrix.target }}.tar.gz > taskwarrior-tui-${{ matrix.target }}.sha256 - fi - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: taskwarrior-tui-${{ matrix.target }} - path: target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz - - name: Releasing assets - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v2 - with: - files: | - target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.tar.gz - target/${{ matrix.target }}/release/taskwarrior-tui-${{ matrix.target }}.sha256 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + call_build: + uses: ./.github/workflows/build.yml homebrew: name: Bump Homebrew formula From ad449a53a3ec9713431ec44d55be8a65a36a1462 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Wed, 13 Nov 2024 17:02:07 +0100 Subject: [PATCH 8/9] feat: Add code coverage to CI --- .../actions/install-taskwarrior/action.yml | 13 +-- .github/workflows/cd.yml | 80 ++----------------- .github/workflows/ci.yml | 34 ++++---- .github/workflows/generate_coverage.yml | 68 ++++++++++++++++ 4 files changed, 100 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/generate_coverage.yml diff --git a/.github/actions/install-taskwarrior/action.yml b/.github/actions/install-taskwarrior/action.yml index 67d663a3..038c2b44 100644 --- a/.github/actions/install-taskwarrior/action.yml +++ b/.github/actions/install-taskwarrior/action.yml @@ -1,7 +1,7 @@ # 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' -description: 'Builds latests stable taskwarrior release install it' +name: Install Taskwarrior +description: Builds latests stable taskwarrior release install it inputs: secret_gh_token: description: "GH token used for downloading the release asset" @@ -13,7 +13,7 @@ runs: using: "composite" steps: - name: Update apt - run: sudo apt get update + run: sudo apt-get update shell: bash - name: Install libuuid run: sudo apt-get install uuid-dev uuid-runtime @@ -51,13 +51,13 @@ runs: uses: actions/cache/restore@v4 with: path: /tmp/task.deb - key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }} + key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}-rust-${{ inputs.rust_toolchain }} - 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 + toolchain: ${{ inputs.rust_toolchain }} override: false - name: Extract taskwarrior source code if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true' @@ -101,3 +101,6 @@ runs: - name: Install taskwarrior run: sudo dpkg -i /tmp/task.deb shell: bash + - name: Test if installation worked + run: task --version + shell: bash \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index cbe506e8..f1b29e5c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,9 +11,12 @@ permissions: contents: write jobs: - call_build: + build: uses: ./.github/workflows/build.yml + generate_coverage: + uses: ./.github/workflows/generate_coverage.yml + homebrew: name: Bump Homebrew formula runs-on: macos-latest @@ -96,77 +99,4 @@ jobs: - name: Install cargo-aur run: cargo install cargo-aur - name: Build aur package - run: cargo aur - - grcov: - runs-on: ubuntu-latest - env: - TASKRC: taskwarrior-testdata/.taskrc - TASKDATA: taskwarrior-testdata/.task - RUST_BACKTRACE: full - steps: - - uses: actions/checkout@v4 - - run: sudo apt-get update - - name: 'Install Taskwarrior' - uses: ./.github/actions/install-taskwarrior - with: - secret_gh_token: ${{ secrets.GITHUB_TOKEN }} - - run: | - task --version - - uses: actions/checkout@v4 - with: - repository: kdheepak/taskwarrior-testdata - path: taskwarrior-testdata - - 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: - command: clean - - name: Build taskwarrior-tui with coverage - uses: clechasseur/rs-cargo@v2 - with: - command: build - env: - RUSTFLAGS: "-Cinstrument-coverage" - - name: Run taskwarrior-tui tests in coverage environment - uses: clechasseur/rs-cargo@v2 - with: - command: test - args: --worksoace - env: - RUSTFLAGS: "-Cinstrument-coverage" - LLVM_PROFILE_FILE: "your_name-%p-%m.profraw" - - name: Install grcov - uses: clechasseur/rs-cargo@v2 - with: - command: install - args: grcov - - name: Gather coverage data - run: | - mkdir ./target/debug/coverage/ - grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/ - shell: bash - - name: Coveralls upload - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel: true - file: ./target/debug/coverage/lcov - - grcov_finalize: - runs-on: ubuntu-latest - needs: grcov - steps: - - name: Coveralls finalization - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + run: cargo aur \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23728a6d..7f66c6ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,37 +19,41 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - env: - TASKRC: taskwarrior-testdata/.taskrc - TASKDATA: taskwarrior-testdata/.task - RUST_BACKTRACE: full steps: - uses: actions/checkout@v4 - - run: sudo apt-get update - - name: 'Install Taskwarrior' + - name: Install Taskwarrior uses: ./.github/actions/install-taskwarrior with: secret_gh_token: ${{ secrets.GITHUB_TOKEN }} - - run: | - task --version - - uses: actions/checkout@v4 - with: - repository: kdheepak/taskwarrior-testdata - path: taskwarrior-testdata - run: | # prepare taskwarrior, initial setup task rc.confirmation=off || echo 0 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable - override: true + override: true + - name: Install testdata + uses: actions/checkout@v4 + with: + repository: kdheepak/taskwarrior-testdata + path: taskwarrior-testdata - uses: clechasseur/rs-cargo@v2 with: command: test args: --workspace -- --nocapture + env: + TASKRC: taskwarrior-testdata/.taskrc + TASKDATA: taskwarrior-testdata/.task + RUST_BACKTRACE: full + + + generate_coverage: + uses: ./.github/workflows/generate_coverage.yml + # Avoid double-compiling taskwarrior if not cached, or wasting CI time if tests fail + needs: test fmt: - name: Rustfmt + name: Rustfm runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -76,4 +80,4 @@ jobs: - uses: clechasseur/rs-cargo@v2 with: command: clippy - args: -- -D warnings + args: -- -D warnings \ No newline at end of file diff --git a/.github/workflows/generate_coverage.yml b/.github/workflows/generate_coverage.yml new file mode 100644 index 00000000..d0ad46b2 --- /dev/null +++ b/.github/workflows/generate_coverage.yml @@ -0,0 +1,68 @@ +name: generate_coverage + +on: + workflow_call + +jobs: + grcov: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Taskwarrior + uses: ./.github/actions/install-taskwarrior + with: + secret_gh_token: ${{ secrets.GITHUB_TOKEN }} + - run: | + # prepare taskwarrior, initial setup + task rc.confirmation=off || echo 0 + + - name: Install Rust toolchain for grcov compilation + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + override: true + - name: Install grcov + uses: clechasseur/rs-cargo@v2 + with: + command: install + args: grcov + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly + override: true + components: llvm-tools-preview + - name: Checkout testdata + uses: actions/checkout@v4 + with: + repository: kdheepak/taskwarrior-testdata + path: taskwarrior-testdata + - name: Build taskwarrior-tui with coverage + uses: clechasseur/rs-cargo@v2 + with: + command: build + env: + RUSTFLAGS: "-Cinstrument-coverage" + - name: Run taskwarrior-tui tests in coverage environment + uses: clechasseur/rs-cargo@v2 + with: + command: test + args: --workspace -- --nocapture + env: + TASKRC: taskwarrior-testdata/.taskrc + TASKDATA: taskwarrior-testdata/.task + RUST_BACKTRACE: full + RUSTFLAGS: "-Cinstrument-coverage" + LLVM_PROFILE_FILE: "your_name-%p-%m.profraw" + + - name: Gather coverage data + run: | + mkdir ./target/debug/coverage/ + grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/ + shell: bash + - name: Coveralls upload + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: ./target/debug/coverage/lcov \ No newline at end of file From 016504904f53a8c2fd547ff6e77cfd392de47d83 Mon Sep 17 00:00:00 2001 From: RedEtherbloom Date: Wed, 13 Nov 2024 18:16:15 +0100 Subject: [PATCH 9/9] refactor: Apply clippy lint I want the CI run to be unambiguous, as we're changing a lot in CI. --- src/app.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index 63850d12..66c36a76 100644 --- a/src/app.rs +++ b/src/app.rs @@ -505,17 +505,14 @@ impl TaskwarriorTui { let virtual_tag_names_in_precedence = &self.config.rule_precedence_color; let mut style = Style::default(); for tag_name in virtual_tag_names_in_precedence.iter().rev() { - match tag_name.as_str() { - "project." => { - let s = self - .config - .color - .get(&format!("color.project.{}", project[0])) - .copied() - .unwrap_or_default(); - style = style.patch(s); - } - &_ => {} + if tag_name.as_str() == "project." { + let s = self + .config + .color + .get(&format!("color.project.{}", project[0])) + .copied() + .unwrap_or_default(); + style = style.patch(s); } } style