diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml deleted file mode 100644 index 7d520f5..0000000 --- a/.github/workflows/test-coverage.yaml +++ /dev/null @@ -1,69 +0,0 @@ -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: test-coverage - -permissions: - contents: read - pull-requests: write - -jobs: - test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::covr, any::xml2 - needs: coverage - - - name: Install package dependencies - run: | - install.packages("pak") - pak::pkg_install(".", dependencies = TRUE) - shell: Rscript {0} - - - name: Test coverage - run: | - cov <- covr::package_coverage( - quiet = FALSE, - clean = FALSE, - install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") - ) - print(cov) - covr::to_cobertura(cov) - shell: Rscript {0} - - - uses: codecov/codecov-action@v5 - with: - # Fail if error if not on PR, or if on PR and token is given - fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} - files: ./cobertura.xml - plugins: noop - disable_search: true - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Show testthat output - if: always() - run: | - ## -------------------------------------------------------------------- - find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload test results - if: failure() - uses: actions/upload-artifact@v4 - with: - name: coverage-test-failures - path: ${{ runner.temp }}/package diff --git a/.github/workflows/update-readme.yaml b/.github/workflows/update-readme.yaml new file mode 100644 index 0000000..a58c9ee --- /dev/null +++ b/.github/workflows/update-readme.yaml @@ -0,0 +1,92 @@ +name: update-readme + +on: + pull_request: + branches: [main, master] + +jobs: + bot-job: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Pandoc + uses: r-lib/actions/setup-pandoc@v2 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + r-version: 'release' + use-public-rspm: true + + - name: Install R dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rmarkdown + needs: check + + - name: List installed packages + run: | + Rscript -e "print(installed.packages()[,c('Package','Version')])" + + - name: Install package + run: | + R CMD INSTALL . + + - name: Render README + run: | + R -e "rmarkdown::render('README.Rmd', output_format = 'github_document')" + git add README.md + + - name: Check staged changes + run: | + if git diff --cached --quiet --exit-code; then + echo "changed=false" >> $GITHUB_ENV + else + echo "changed=true" >> $GITHUB_ENV + fi + + - name: Commit and push changes + if: env.changed == 'true' + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git commit -m "Update README" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on PR when changed + if: env.changed == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Updated repo README file." + }) + + - name: Comment on PR when unchanged + if: env.changed == 'false' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Repo README file is up to date. Nothing to commit." + }) \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index f2e8c42..0a6ea20 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Imports: tibble, tidyr Suggests: + covr, testthat Remotes: stitam/breakpoint diff --git a/README.Rmd b/README.Rmd index e8da3fa..bd60f17 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,9 +20,34 @@ knitr::opts_chunk$set( +```{r coverage, echo=FALSE} +cov <- covr::package_coverage() +pct <- covr::percent_coverage(cov) +pct_label <- sprintf("%.1f%%", pct) + +# Choose badge color based on coverage +col <- if (pct >= 90) { + "brightgreen" + } else if (pct >= 75) { + "yellow" + } else if (pct >= 50) { + "orange" + } else { + "red" + } + +badge_url <- sprintf( + "https://img.shields.io/badge/coverage-%s-%s", + URLencode(pct_label), + col +) +``` + [![status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![R build status](https://github.com/sbthandras/tailor/workflows/R-CMD-check/badge.svg)](https://github.com/sbthandras/tailor/actions) -[![Coverage](https://codecov.io/github/sbthandras/tailor/graph/badge.svg?branch=main)](https://app.codecov.io/gh/sbthandras/tailor/branch/main) +```{r coverage-badge, echo=FALSE, results='asis'} +cat(sprintf("[![Coverage](%s)](#test-coverage)\n\n", badge_url)) +``` [![DOI](https://img.shields.io/badge/DOI-10.64898%2F2026.02.20.706991-blue)](https://doi.org/10.64898/2026.02.20.706991) diff --git a/README.md b/README.md index ee30312..df3758b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![R build status](https://github.com/sbthandras/tailor/workflows/R-CMD-check/badge.svg)](https://github.com/sbthandras/tailor/actions) -[![Coverage](https://codecov.io/github/sbthandras/tailor/graph/badge.svg?branch=main)](https://app.codecov.io/gh/sbthandras/tailor/branch/main) +[![Coverage](https://img.shields.io/badge/coverage-12.1%25-red)](#test-coverage) [![DOI](https://img.shields.io/badge/DOI-10.64898%2F2026.02.20.706991-blue)](https://doi.org/10.64898/2026.02.20.706991) @@ -83,7 +83,7 @@ but both ranges were classified as conserved, so they were merged plot(ps) ``` - + Depending on the method used for detecting breakpoints, the length of the identified adapter may differ. By default, `find_breakpoints()` uses @@ -117,7 +117,7 @@ clusters <- cluster_adapters(amat) plot(amat, clusters = clusters) ``` - + ## Citation diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png new file mode 100644 index 0000000..a2e324d Binary files /dev/null and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png new file mode 100644 index 0000000..0bebf76 Binary files /dev/null and b/man/figures/README-unnamed-chunk-6-1.png differ