fix copy constructors for C++ 11/14 / ammend RNG note / partial int-d… #88
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | |
| # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| name: test-coverage | |
| jobs: | |
| test-coverage: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - 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 | |
| needs: coverage | |
| - name: Install package | |
| run: | | |
| options(warn = 2) | |
| pak::local_install("./", dependencies = TRUE) | |
| # Override Makevars to avoid _FORTIFY_SOURCE warning with -O0 | |
| # covr adds --coverage which needs -O0, but _FORTIFY_SOURCE needs -O | |
| makevars_content <- paste( | |
| "PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)", | |
| "PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)", | |
| sep = "\n" | |
| ) | |
| writeLines(makevars_content, "./extended-tests/cpp4rtest/src/Makevars") | |
| pak::local_install("./extended-tests/cpp4rtest", dependencies = TRUE) | |
| shell: Rscript {0} | |
| - name: Test coverage | |
| run: | | |
| coverage <- covr::package_coverage( | |
| "./extended-tests/cpp4rtest", | |
| type = "all", | |
| quiet = FALSE | |
| ) | |
| # Debug: show coverage breakdown | |
| print(coverage) | |
| percent_exact <- covr::percent_coverage(coverage) | |
| percent <- floor(percent_exact) # Use floor for conservative estimate | |
| cat("\nCoverage:", percent_exact, "% (rounded down to", percent, "%)\n") | |
| # Create badge color based on coverage | |
| if (percent >= 90) { | |
| color <- "brightgreen" | |
| } else if (percent >= 80) { | |
| color <- "green" | |
| } else if (percent >= 70) { | |
| color <- "yellowgreen" | |
| } else if (percent >= 60) { | |
| color <- "yellow" | |
| } else if (percent >= 50) { | |
| color <- "orange" | |
| } else { | |
| color <- "red" | |
| } | |
| writeLines(as.character(percent), "coverage_percent.txt") | |
| writeLines(color, "coverage_color.txt") | |
| shell: Rscript {0} | |
| - name: Generate coverage badge | |
| run: | | |
| COVERAGE=$(cat coverage_percent.txt) | |
| COVERAGE_COLOR=$(cat coverage_color.txt) | |
| echo "Coverage: $COVERAGE%" | |
| echo "Color: $COVERAGE_COLOR" | |
| mkdir -p badges | |
| curl -s "https://raw.githubusercontent.com/pachadotdev/ghacoveragebadge/refs/heads/main/badges/${COVERAGE_COLOR}.svg" > badges/coverage.svg | |
| # each badge contains a placeholder {{ COVERAGE }} that we replace with the actual coverage percentage | |
| sed -i "s/{{ COVERAGE }}/${COVERAGE}/g" badges/coverage.svg | |
| - name: Commit coverage badge | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| # Save the badge file before switching branches | |
| cp badges/coverage.svg /tmp/coverage.svg | |
| # Create or switch to coverage branch | |
| git checkout -B coverage | |
| # Remove everything except .git | |
| git rm -rf . || true | |
| # Restore just the badge | |
| mkdir -p badges | |
| cp /tmp/coverage.svg badges/coverage.svg | |
| git add badges/coverage.svg | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update coverage badge" | |
| git push --force origin coverage | |
| else | |
| echo "No changes to commit" | |
| fi | |
| # Switch back to main | |
| git checkout main |