nishita #1472
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
| name: Test Suite | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| jobs: | |
| R-CMD-check: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test-suite: [ R_coverage, JS_coverage, CRAN ] | |
| name: ${{ matrix.test-suite }} | |
| env: | |
| TEST_SUITE: ${{ matrix.test-suite }} | |
| GITHUB_PAT: ${{ secrets.PAT_GITHUB }} | |
| GH_ACTION: "ENABLED" | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| 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 toby.hocking@r-project.org | |
| - 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: | | |
| 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 | |
| - 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..." | |
| 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' | |
| 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 |