Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add badge for ignored tests #149

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Coverage
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ] # TODO

jobs:
coverage:
Expand All @@ -22,6 +24,8 @@ jobs:
percent_coverage="$(cat target/tarpaulin-report.json | jq .coverage)"
printf '::notice title=Coverage (lines %%)::%s' "$percent_coverage"
echo "LINES_PERCENT=$percent_coverage" >> "$GITHUB_ENV"
env:
TEST_TIMEOUT_MULTIPLIER: 10
- name: Upload to gist
run: ./scripts/percent_to_shields_gist coverage "$LINES_PERCENT"
env:
Expand Down Expand Up @@ -49,11 +53,35 @@ jobs:
fi
json_text="$(echo '{}' |
jq -c '{schemaVersion: 1, label: $badge_label, color: $color, message: $message}' \
--arg badge_label "Pending TODOs" --arg color "$color" --arg message "$todos_count")"
--arg badge_label "Pending TODOs" --arg color "$color" --arg message "$todos_count")"

printf '::notice title=TODOs Count::%s' "$todos_count"
gh gist edit "$GIST_URL" <(echo "$json_text")
env:
GIST_URL: ${{ vars.TODOS_GIST_URL }}
GH_TOKEN: ${{ secrets.API_TOKEN }}

- name: Count Ignored Tests
run: |
rs_ignored="$(find . -not -path './target/*' -name '*.rs' -exec grep --fixed-strings -Hno '#[ignore]' {} \; | wc -l)"
integ_ignored="$(cd tests/md_cases/ ; find . -name '*.toml' -exec grep -Hno '^ignore\b' {} \; | wc -l)"
total_ignored="$(( $rs_ignored + $integ_ignored ))"

if [ "$total_ignored" -eq 0 ]; then
color=green
else
color=orange
fi
json_text="$(echo '{}' |
jq -c '{schemaVersion: 1, label: $badge_label, color: $color, message: $message}' \
--arg badge_label "Ignored Tests" --arg color "$color" --arg message "$total_ignored")"

printf '::notice title=Ignored Tests Count::%s' "$total_ignored"
gh gist edit "$GIST_URL" <(echo "$json_text")
env:
GIST_URL: ${{ vars.IGNOREDS_GIST_URL }}
GH_TOKEN: ${{ secrets.API_TOKEN }}




5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Code Coverage][coverage-shield]][coverage-link]
[![Build status][build-shield]][build-link]
[![Pending TODOs][todos-shield]][todos-link]
[![Ignored tests][ignoreds-shield]][ignoreds-link]

[coverage-shield]: https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Fyshavit%2F53901a0115b596e015a891c41fb0f256%2Fraw%2Fmdq-coverage.json

Expand All @@ -16,6 +17,10 @@

[todos-link]: https://github.com/search?q=repo%3Ayshavit%2Fmdq+NOT+path%3A.github%2Fworkflows%2Fcoverage.yml+NOT+path%3AREADME.md+todo&type=code

[ignoreds-shield]: https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Fyshavit%2F782a8dc5f77d2cf4b1c774da72636f00%2Fraw%2Fmdq-ignoreds.json

[ignoreds-link]: https://github.com/search?q=repo%3Ayshavit%2Fmdq+%28%28path%3A%2F%5C.rs%24%2F+%22%23%5Bignore%5D%22%29+OR+%28path%3Atests%2Fmd_cases+%2F%5Eignore%2F%29%29&type=code

## What is mdq?

mdq aims to do for Markdown what jq does for JSON: provide an easy way to zero in on specific parts of a document.
Expand Down
13 changes: 12 additions & 1 deletion src/utils_for_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ mod test_utils {
};
}

#[macro_export]
macro_rules! test_delay_ms {
($i:literal) => {{
time::Duration::from_millis(
$i * option_env!("TEST_TIMEOUT_MULTIPLIER")
.map(|s| s.parse::<u64>().expect("bad value for TEST_TIMEOUT_MULTIPLIER"))
.unwrap_or(1),
)
}};
}

/// Creates a static object named `$name` that looks for all the variants of enum `E`.
///
/// ```
Expand Down Expand Up @@ -59,7 +70,7 @@ mod test_utils {
fn wait_for_all(&self) {
use std::{thread, time};

let timeout = time::Duration::from_millis(500);
let timeout = crate::test_delay_ms!(500);
let retry_delay = time::Duration::from_millis(50);
let start = time::Instant::now();
loop {
Expand Down
Loading