tests begin #3
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: | |
| # workflow_run: | |
| # workflows: ["CI"] # setup_ee.yml 的 name 字段 | |
| # types: | |
| # - completed | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| name: test-coverage | |
| permissions: read-all | |
| jobs: | |
| test-coverage: | |
| # if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - {os: ubuntu-latest, r: 'release'} | |
| - {os: windows-latest, r: 'release'} | |
| # - {os: macos-latest, r: 'release'} | |
| # - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | |
| # - {os: ubuntu-latest, r: 'release'} | |
| # - {os: ubuntu-latest, r: 'oldrel-1'} | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| ## setup python | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| uv pip install earthengine-api --system | |
| ## setup R | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| install-quarto: 'false' | |
| cache: true # 默认启用,设为 false 禁用 | |
| cache-version: 1 # 修改此数字强制刷新缓存 | |
| extra-packages: any::covr, any::xml2 | |
| needs: coverage | |
| - name: setup r-reticulate | |
| shell: Rscript {0} | |
| run: | | |
| python = Sys.which("python") | |
| writeLines(sprintf("RETICULATE_PYTHON=%s", python), Sys.getenv("GITHUB_ENV")) | |
| print(reticulate::py_config()) | |
| - name: Test coverage | |
| run: | | |
| cov <- covr::package_coverage( | |
| quiet = FALSE, | |
| clean = FALSE, | |
| install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") | |
| ) | |
| covr::to_cobertura(cov) | |
| shell: Rscript {0} | |
| - 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 | |
| - uses: codecov/codecov-action@v5 | |
| with: | |
| fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} | |
| file: ./cobertura.xml | |
| plugin: noop | |
| disable_search: true | |
| token: ${{ secrets.CODECOV_TOKEN }} |