-
Notifications
You must be signed in to change notification settings - Fork 27
Combine upload of R and JS coverage #260
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
Open
suhaani-agarwal
wants to merge
22
commits into
master
Choose a base branch
from
coverage-upload
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4f66215
uplaod r and js coverage together after both are computed
suhaani-agarwal d5b7a2e
updated version of actions/upload-artifact
suhaani-agarwal a2f1ce1
added setup for cleaner code
suhaani-agarwal 38acf60
no setup
suhaani-agarwal 1bdfce0
replaced to_lcov
suhaani-agarwal d4edb31
Merge branch 'master' into coverage-upload
suhaani-agarwal d44e6e0
seperate flags
suhaani-agarwal e9d98bf
Merge remote-tracking branch 'origin/master' into coverage-upload
suhaani-agarwal 559209f
Merge remote-tracking branch 'origin/coverage-upload' into coverage-u…
suhaani-agarwal ecc349e
normalisation of paths
suhaani-agarwal afd4306
test commit
suhaani-agarwal 53bbce8
fixed paths
suhaani-agarwal 58c00fd
actions/checkout@v3 added
suhaani-agarwal 3ee5b4b
test commit
suhaani-agarwal 7fbb434
cleanup
suhaani-agarwal fcc6079
test commit
suhaani-agarwal a442a58
Merge remote-tracking branch 'origin/master' into coverage-upload
suhaani-agarwal 8a2c8b6
removed unnecessary actions in R and JS coverage workflow
suhaani-agarwal 4be6d28
Rscript changes
suhaani-agarwal c4c6d4d
updated NEWS and version++
suhaani-agarwal 2e06d40
Merge remote-tracking branch 'origin/master' into coverage-upload
suhaani-agarwal 1620d93
added back texlive steps to R and JS coverage workflows
suhaani-agarwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,20 +6,58 @@ on: | |
| branches: [main, master] | ||
|
|
||
| jobs: | ||
| R-CMD-check: | ||
| r-tests: | ||
| runs-on: ubuntu-latest | ||
| name: R coverage tests | ||
| env: | ||
| TEST_SUITE: R_coverage | ||
| GITHUB_PAT: ${{ secrets.PAT_GITHUB }} | ||
| GH_ACTION: "ENABLED" | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: install and update texlive | ||
| run: /usr/bin/sudo DEBIAN_FRONTEND=noninteractive apt update -y -qq | ||
| - run: /usr/bin/sudo DEBIAN_FRONTEND=noninteractive apt install tidy texlive texlive-fonts-extra -y | ||
| - uses: r-lib/actions/setup-r@v2 | ||
| - uses: r-lib/actions/setup-r-dependencies@v2 | ||
|
|
||
| - name: install package | ||
| run: R CMD INSTALL . | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| test-suite: [ R_coverage, JS_coverage, CRAN ] | ||
| - name: git config user.name | ||
| run: git config --global user.name "GitHub Actions" | ||
|
|
||
| - name: git config user.email | ||
| run: git config --global user.email [email protected] | ||
|
|
||
| name: ${{ matrix.test-suite }} | ||
| env: | ||
| TEST_SUITE: ${{ matrix.test-suite }} | ||
| - name: Run R tests and generate coverage | ||
| run: | | ||
| Rscript -e "if (!requireNamespace('covr', quietly=TRUE)) install.packages('covr'); cov <- covr::package_coverage(type='tests', test_files = "tests/testthat.R"); covr::to_cobertura(cov, file='r-coverage.xml')" | ||
|
|
||
| - name: Normalize R coverage paths | ||
| run: | | ||
| if [ -f "r-coverage.xml" ]; then | ||
| Rscript -e " | ||
| content <- paste(readLines('r-coverage.xml', warn = FALSE), collapse='\n') | ||
| content <- gsub('<sources>.*?</sources>', '<sources><source>.</source></sources>', content) | ||
| content <- gsub('\\\\\\\\', '/', content) | ||
| writeLines(content, 'r-coverage.xml') | ||
| " | ||
| fi | ||
|
|
||
| - name: Upload R coverage artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: r-coverage | ||
| path: r-coverage.xml | ||
|
|
||
| js-tests: | ||
| runs-on: ubuntu-latest | ||
| name: JS coverage tests | ||
| env: | ||
| TEST_SUITE: JS_coverage | ||
| GITHUB_PAT: ${{ secrets.PAT_GITHUB }} | ||
| GH_ACTION: "ENABLED" | ||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: install and update texlive | ||
|
|
@@ -38,48 +76,84 @@ jobs: | |
| run: git config --global user.email [email protected] | ||
|
|
||
| - name: Setup Node.js | ||
| if: matrix.test-suite == 'JS_coverage' | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Install Node.js dependencies | ||
| if: matrix.test-suite == 'JS_coverage' | ||
| run: | | ||
| npm install v8-to-istanbul | ||
| echo "Node modules installed" | ||
|
|
||
| - name: run tests | ||
| run: npm install v8-to-istanbul | ||
|
|
||
| - name: Run JS tests and convert coverage | ||
| run: | | ||
| if [ "$TEST_SUITE" == "CRAN" ]; then | ||
| bash build.sh | ||
| elif [ "$TEST_SUITE" == "JS_coverage" ]; then | ||
| echo "Running testthat with JS coverage collection..." | ||
| Rscript -e "source('tests/testthat.R', chdir = TRUE)" | ||
| else | ||
| echo "Running testthat with R coverage collection..." | ||
| Rscript -e 'covr::codecov(quiet = FALSE, type = "tests", test_files = "tests/testthat.R", flags = "r")' | ||
| fi | ||
| Rscript -e "source('tests/testthat.R', chdir = TRUE)" | ||
|
|
||
| - name: Convert JS coverage to Istanbul format | ||
| if: matrix.test-suite == 'JS_coverage' | ||
| run: | | ||
| if [ -f "tests/testthat/js-coverage.json" ]; then | ||
| echo "Converting JS coverage to LCOV format..." | ||
| echo "Converting JS coverage to Istanbul format..." | ||
| node v8-to-istanbul.js | ||
| else | ||
| echo "No JS coverage file found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Upload JS coverage to Codecov | ||
| if: matrix.test-suite == 'JS_coverage' | ||
| - name: Upload JS coverage artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: js-coverage | ||
| path: coverage-istanbul.json | ||
|
|
||
| CRAN: | ||
| runs-on: ubuntu-latest | ||
| name: CRAN checks | ||
| env: | ||
| TEST_SUITE: CRAN | ||
| GITHUB_PAT: ${{ secrets.PAT_GITHUB }} | ||
| GH_ACTION: "ENABLED" | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: install and update texlive | ||
| run: /usr/bin/sudo DEBIAN_FRONTEND=noninteractive apt update -y -qq | ||
| - run: /usr/bin/sudo DEBIAN_FRONTEND=noninteractive apt install tidy texlive texlive-fonts-extra -y | ||
| - uses: r-lib/actions/setup-r@v2 | ||
| - uses: r-lib/actions/setup-r-dependencies@v2 | ||
|
|
||
| - name: install package | ||
| run: R CMD INSTALL . | ||
|
|
||
| - name: git config user.name | ||
| run: git config --global user.name "GitHub Actions" | ||
|
|
||
| - name: git config user.email | ||
| run: git config --global user.email [email protected] | ||
|
|
||
| - name: run CRAN build | ||
| run: bash build.sh | ||
|
|
||
| upload-coverage: | ||
| runs-on: ubuntu-latest | ||
| name: Upload combined coverage to Codecov | ||
| needs: [r-tests, js-tests] | ||
| if: always() | ||
| env: | ||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
| steps: | ||
| - name: Checkout repository (needed so Codecov can find source files) | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Download R coverage artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: r-coverage | ||
| path: ./ | ||
|
|
||
| - name: Download JS coverage artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: js-coverage | ||
| path: ./ | ||
|
|
||
| - name: Upload to Codecov | ||
| run: | | ||
| if [ -f "coverage-istanbul.json" ]; then | ||
| curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
| chmod +x codecov | ||
| ./codecov -f coverage-istanbul.json -t ${{ secrets.CODECOV_TOKEN }} --flags javascript | ||
| else | ||
| echo "No coverage file found" | ||
| exit 1 | ||
| fi | ||
| curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
| chmod +x codecov | ||
| ./codecov -f "r-coverage.xml" -f "coverage-istanbul.json" -t $CODECOV_TOKEN | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better if this job be moved to a separate file?