From 689900cc181f5ff9c26ded2878f4355fcd6f0f80 Mon Sep 17 00:00:00 2001 From: hijackthe2 <2948278083@qq.com> Date: Fri, 27 Oct 2023 15:18:45 +0800 Subject: [PATCH] ci: add configurations to setup fscache Since using `/dev/cachefiles` requires sudo mode, so some environment variables are defined and we use `sudo -E` to pass these environment variables to sudo operations. The script file for enabling fscache is misc/fscache/setup.sh Signed-off-by: hijackthe2 <2948278083@qq.com> --- .github/workflows/smoke.yml | 13 +++++++++++-- misc/fscache/setup.sh | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 misc/fscache/setup.sh diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 5a0cf852060..7522029f1d2 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -610,9 +610,13 @@ jobs: shared-key: nydus-build - name: Install cargo nextest uses: taiki-e/install-action@nextest + - name: Fscache Setup + run: sudo bash misc/fscache/setup.sh - name: Unit Test run: | - make ut-nextest + CARGO_HOME=${HOME}/.cargo + CARGO_BIN=$(which cargo) + sudo -E CARGO=${CARGO_BIN} make ut-nextest nydus-unit-test-coverage: runs-on: ubuntu-latest @@ -626,8 +630,13 @@ jobs: cache-on-failure: true - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov + - name: Fscache Setup + run: sudo bash misc/fscache/setup.sh - name: Generate code coverage - run: make coverage-codecov + run: | + CARGO_HOME=${HOME}/.cargo + CARGO_BIN=$(which cargo) + sudo -E CARGO=${CARGO_BIN} make coverage-codecov - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/misc/fscache/setup.sh b/misc/fscache/setup.sh new file mode 100644 index 00000000000..da312b53ece --- /dev/null +++ b/misc/fscache/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script should be executed in root mode! + +apt update +apt install -y cachefilesd +apt list --installed | grep cachefilesd +chmod a+w /etc/default/cachefilesd +sed -i 's/#RUN=yes/RUN=yes/' /etc/default/cachefilesd +cat /etc/default/cachefilesd +/sbin/modprobe -qab cachefiles +/sbin/cachefilesd -f /etc/cachefilesd.conf +systemctl status cachefilesd +[ -c /dev/cachefiles ] && echo "cachefilesd is successfully enabled" +pid=$(lsof /dev/cachefiles | awk '{if (NR>1) {print $2}}') +kill -9 $pid +echo "/dev/cachefiles is available now"