Repository: bearcove/loona (language: rust)

Issue:
Move off of codecov
Sentry now owns codecov, which means:

  - they're pretending it's open-source (it's BUSL)
  - the "free for OSS" tier is gone, it's now a generic "free for 5 active developers, 250 uploads a month" tier, which makes it unsuitable for this
  - they have a "proof of concept" self-hosted repo for if you want to run it on your macbook, this is also unsuitable, also the README says it's based on a deprecated version and they apparently haven't had time to remove license checking

I probably know people who know people who can get free credits or carve whatever exception for this repo, but I'm not interested: it seems to me codecov is going the same way travis did, and this time I'm not sure what replacement there is, apart from just.. hosting the llvm-cov HTML reports somewhere and writing scripts to track coverage, I guess.
Move off of codecov
Sentry now owns codecov, which means:

  - they're pretending it's open-source (it's BUSL)
  - the "free for OSS" tier is gone, it's now a generic "free for 5 active developers, 250 uploads a month" tier, which makes it unsuitable for this
  - they have a "proof of concept" self-hosted repo for if you want to run it on your macbook, this is also unsuitable, also the README says it's based on a deprecated version and they apparently haven't had time to remove license checking

I probably know people who know people who can get free credits or carve whatever exception for this repo, but I'm not interested: it seems to me codecov is going the same way travis did, and this time I'm not sure what replacement there is, apart from just.. hosting the llvm-cov HTML reports somewhere and writing scripts to track coverage, I guess.


Discussion / hints:
update: their pricing page still has an "open source" column https://about.codecov.io/pricing/

so maybe their UI is just doing a shitty job and is scary for no good reason:

<img width="336" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/742ef622-b8b4-4ef6-b193-00c4aa12458c">

<img width="1131" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/72366598-8468-451b-988a-9a8cec785d0c">

<img width="881" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/512d7e8d-9a4b-461e-90f6-f7a20bf36fff">

update: their pricing page still has an "open source" column https://about.codecov.io/pricing/

so maybe their UI is just doing a shitty job and is scary for no good reason:

<img width="336" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/742ef622-b8b4-4ef6-b193-00c4aa12458c">

<img width="1131" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/72366598-8468-451b-988a-9a8cec785d0c">

<img width="881" alt="image" src="https://github.com/hapsoc/fluke/assets/7998310/512d7e8d-9a4b-461e-90f6-f7a20bf36fff">


Fix patch:
diff --git a/.gitignore b/.gitignore
index 3168f01d..cb4af2cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
+coverage
 target
+target-cov
 Cargo.lock
 *.lcov
 lcov.info
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ceeb0799..5bb38e79 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,5 +3,5 @@
 	"rust-analyzer.inlayHints.lifetimeElisionHints.useParameterNames": true,
 	"coverage-gutters.showLineCoverage": true,
 	"coverage-gutters.showRulerCoverage": true,
-	"coverage-gutters.coverageReportFileName": "target/llvm-cov/html/index.html"
+	"coverage-gutters.coverageReportFileName": "coverage/html/index.html"
 }
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6b9ce0b8..55fc1f9c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,7 +7,9 @@ The highest-impact work right now is probably picking up an h2spec
 case and making it pass, or tackling some of the `TODO:` or `FIXME:`
 in the code.
 
-More test coverage is always welcome, it's tracked with codecov.
+More test coverage is always welcome, it's tracked via llvm-cov, GitHub
+actions will comment on PR with coverage changes, and you can see the
+coverage for yourself with `just cov`, in the `coverage/html` directory.
 
 Some more design needs to happen, especially re: configuration and
 introspection of running HTTP services, that'll happen when H1/H2
diff --git a/Justfile b/Justfile
index 33aada4b..679074a2 100644
--- a/Justfile
+++ b/Justfile
@@ -7,20 +7,13 @@ _default:
 ci-test:
 	#!/bin/bash -eux
 	just build-testbed
-	source <(cargo llvm-cov show-env --export-prefix)
-	cargo llvm-cov clean --workspace
-	cargo nextest run --manifest-path crates/fluke-hpack/Cargo.toml --features interop-tests --release
-	cargo nextest run --manifest-path crates/fluke/Cargo.toml --profile ci
-	cargo nextest run --manifest-path test-crates/fluke-curl-tests/Cargo.toml --profile ci
-	cargo run --manifest-path test-crates/fluke-h2spec/Cargo.toml -- generic -j 'target/h2spec-generic.xml'
-	cargo run --manifest-path test-crates/fluke-h2spec/Cargo.toml -- hpack -j 'target/h2spec-hpack.xml'
-	cargo run --manifest-path test-crates/fluke-h2spec/Cargo.toml -- http2 -j 'target/h2spec-http2.xml'
-	cargo llvm-cov report --lcov --output-path coverage.lcov
-	codecov
+	just cov
 
 cov:
-	cargo llvm-cov nextest --lcov --output-path lcov.info
-	cargo llvm-cov report --html
+	scripts/cov.sh
+
+quick-cov:
+	SKIP_H2SPEC=1 scripts/cov.sh
 
 # Run all tests with cargo nextest
 test *args:
@@ -40,7 +33,7 @@ h2spec *args:
 	#!/bin/bash -eux
 	export RUST_LOG="${RUST_LOG:-fluke=debug,fluke_hpack=info}"
 	export RUST_BACKTRACE=1
-	cargo run --bin fluke-h2spec -- {{args}}
+	cargo run --manifest-path test-crates/fluke-h2spec/Cargo.toml -- {{args}}
 
 check:
 	cargo clippy --all-targets --all-features
diff --git a/README.md b/README.md
index 6e60f52d..9d52a956 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,6 @@
 
 [![Crates.io](https://img.shields.io/crates/v/fluke)](https://crates.io/crates/fluke)
 [![test pipeline](https://github.com/hapsoc/fluke/actions/workflows/test.yml/badge.svg)](https://github.com/hapsoc/fluke/actions/workflows/test.yml?query=branch%3Amain)
-[![Coverage Status (codecov.io)](https://codecov.io/gh/hapsoc/fluke/branch/main/graph/badge.svg)](https://codecov.io/gh/hapsoc/fluke/)
 
 An experimental, HTTP/1.1 and HTTP/2 implementation in Rust on top of
 [tokio-uring](https://github.com/tokio-rs/tokio-uring).
diff --git a/scripts/cov.sh b/scripts/cov.sh
new file mode 100755
index 00000000..447649b2
--- /dev/null
+++ b/scripts/cov.sh
@@ -0,0 +1,61 @@
+#!/bin/bash -eux
+
+export RUSTFLAGS='-C instrument-coverage --cfg=coverage --cfg=coverage_nightly --cfg=trybuild_no_target -C instrument-coverage --cfg=coverage --cfg=coverage_nightly --cfg=trybuild_no_target'
+
+export CARGO_INCREMENTAL=0
+export CARGO_TARGET_DIR="${PWD}/target-cov"
+
+export COVERAGE_DIR="${PWD}/coverage"
+rm -rf "${COVERAGE_DIR}"
+
+mkdir -p "${COVERAGE_DIR}/raw"
+# must be set before building
+export LLVM_PROFILE_FILE="${COVERAGE_DIR}/raw/fluke-%p-%12m.profraw"
+
+RUSTC_PATH=$(rustup which rustc)
+# replace `bin/rustc` with `lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov`
+LLVM_TOOLS_PATH=${RUSTC_PATH%/*/*}/lib/rustlib/x86_64-unknown-linux-gnu/bin
+LLVM_PROFDATA="${LLVM_TOOLS_PATH}/llvm-profdata"
+"${LLVM_PROFDATA}" --version
+LLVM_COV="${LLVM_TOOLS_PATH}/llvm-cov"
+"${LLVM_COV}" --version
+
+cargo nextest run --verbose --profile ci --manifest-path crates/fluke-hpack/Cargo.toml --features interop-tests --release
+cargo nextest run --verbose --profile ci --manifest-path crates/fluke/Cargo.toml
+cargo nextest run --verbose --profile ci --manifest-path test-crates/fluke-curl-tests/Cargo.toml
+
+cargo build --manifest-path test-crates/fluke-h2spec/Cargo.toml
+# skip if SKIP_H2SPEC is set to 1
+if [[ "${SKIP_H2SPEC:-0}" == "1" ]]; then
+  echo "Skipping h2spec suites"
+else
+	for suite in generic hpack http2; do
+		"${CARGO_TARGET_DIR}"/debug/fluke-h2spec "${suite}" -j "target/h2spec-${suite}.xml"
+	done
+fi
+
+# merge all profiles
+"${LLVM_PROFDATA}" merge -sparse "${COVERAGE_DIR}/raw"/*.profraw -o "${COVERAGE_DIR}/fluke.profdata"
+
+# build llvm-cov argument list
+cover_args=()
+cover_args+=(--instr-profile "${COVERAGE_DIR}/fluke.profdata")
+cover_args+=(--ignore-filename-regex "rustc|.cargo|test-crates|non_uring")
+cover_args+=("${CARGO_TARGET_DIR}"/debug/fluke-h2spec)
+
+# pass *all* binaries/libraries to llvm-cov, including release ones
+# because the fluke-hpack conformance tests are too slow in debug.
+objects=("${CARGO_TARGET_DIR}"/debug/deps/* "${CARGO_TARGET_DIR}"/release/deps/*)
+for object in "${objects[@]}"; do
+  # skip debug files '.d'
+	[[ $object =~ \.d$ ]] && continue
+
+	# skip rust metadata files '.rmeta'
+	[[ $object =~ \.rmeta$ ]] && continue
+
+	cover_args+=(-object "$object")
+done
+
+"${LLVM_COV}" export --format=lcov "${cover_args[@]}" > coverage/lcov.info
+"${LLVM_COV}" show --format=html --output-dir=coverage/html "${cover_args[@]}"
+"${LLVM_COV}" report --format=text "${cover_args[@]}"


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3f02731e..8f75cb4e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -72,6 +72,14 @@ jobs:
           (pushd tools && curl -fL https://github.com/hapsoc/h2spec-binaries/releases/download/72a6b9b/h2spec -o h2spec && chmod +x h2spec && popd)
           just ci-test
           sccache --show-stats
+      - name: Report coverage (zgosalvez/github-actions-report-lcov)
+        uses: zgosalvez/github-actions-report-lcov@v3
+        with:
+          coverage-files: coverage/lcov.info
+          minimum-coverage: 70
+          artifact-name: code-coverage-report
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          working-directory: .
       - name: Upload h2spec Report
         uses: actions/upload-artifact@v3
         if: always() # always run even if the previous step fails
@@ -81,4 +89,4 @@ jobs:
             target/h2spec-generic.xml
             target/h2spec-hpack.xml
             target/h2spec-http2.xml
-          retention-days: 280
+          retention-days: 90
diff --git a/test-crates/fluke-curl-tests/tests/proxy.rs b/test-crates/fluke-curl-tests/tests/proxy.rs
index 0ddaf715..145b1edb 100644
--- a/test-crates/fluke-curl-tests/tests/proxy.rs
+++ b/test-crates/fluke-curl-tests/tests/proxy.rs
@@ -1,5 +1,3 @@
-#![feature(type_alias_impl_trait)]
-
 use fluke::{
     buffet::RollMut,
     h1,