From c625b6e67366c43b34c05cfd21eb4714efb1678a Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Tue, 22 Nov 2022 23:12:50 +0100 Subject: [PATCH] ops(ci): coverage --- .github/workflows/ci.yml | 64 ++++++++++++++++++++++++++++++++++++++++ codecov.yml | 4 +++ xtask/Cargo.toml | 1 + xtask/src/main.rs | 8 +++++ 4 files changed, 77 insertions(+) create mode 100644 codecov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aea04a6455..5d24d3938c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,6 +262,70 @@ jobs: aws s3 cp ./target/optimized-release/iroh-store s3://vorc/iroh-store-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress aws s3 cp ./target/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress + coverage: + name: Coverage + runs-on: ${{ matrix.runner }} + continue-on-error: false + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + rust: [stable] + experimental: [false] + include: + - os: ubuntu-latest + release-os: linux + release-arch: amd64 + protoc-arch: linux-x86_64 + runner: [self-hosted, linux, X64] + env: + RUST_BACKTRACE: full + RUSTV: ${{ matrix.rust }} + steps: + - uses: actions/checkout@master + + - name: Set build arch + run: | + echo "PROTOC_ARCH=${{ matrix.protoc-arch }}" >> $GITHUB_ENV + + - name: Install ${{ matrix.rust }} + run: | + rustup toolchain install --profile default ${{ matrix.rust }} + rustup component add llvm-tools-preview + + - name: Install Protoc + run: | + PROTOC_VERSION=3.20.1 + PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip + curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP + sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc + sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*' + rm -f $PROTOC_ZIP + echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV + echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV + + - name: Install grcov + run: | + mkdir -p "${HOME}/.local/bin" + curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: coverage + timeout-minutes: 30 + env: + # iroh-util/src/lock.rs#test_locks uses a fork() command & fails only in + # GHA if this is not present + # https://twitter.com/steipete/status/921066430220652544?lang=en + # https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/ + OBJC_DISABLE_INITIALIZE_FORK_SAFETY: "YES" + run: | + cargo xtask coverage + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + files: coverage/*.lcov + fmt: name: Rustfmt runs-on: ubuntu-latest diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..674c3bbc1a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +codecov: + notify: + wait_for_ci: false + comment: false \ No newline at end of file diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 4968a2cbb3..e05471ae9a 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -10,4 +10,5 @@ anyhow = "1" clap = { version = "4.0.9", features = ["derive"] } clap_mangen = "0.2.2" dirs-next = "2.0.0" +xtaskops = "0.2.2" iroh = { path = "../iroh" } \ No newline at end of file diff --git a/xtask/src/main.rs b/xtask/src/main.rs index beec765f96..1f874b8bbc 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -18,6 +18,8 @@ struct Cli { #[derive(Debug, Subcommand)] enum Commands { + #[command(about = "generate code coverage report", long_about = None)] + Coverage {}, #[command(about = "build application and man pages", long_about = None)] Dist {}, #[command(about = "build man pages")] @@ -68,6 +70,7 @@ fn main() { fn run_subcommand(args: Cli) -> Result<()> { match args.command { + Commands::Coverage {} => coverage()?, Commands::Dist {} => dist()?, Commands::Man {} => dist_manpage()?, Commands::DevInstall { build } => dev_install(build)?, @@ -86,6 +89,11 @@ fn run_subcommand(args: Cli) -> Result<()> { Ok(()) } +fn coverage() -> Result<()> { + xtaskops::tasks::coverage(false)?; + Ok(()) +} + fn dist() -> Result<()> { let _ = fs::remove_dir_all(&dist_dir()); fs::create_dir_all(&dist_dir())?;