Merge pull request #28 from brownag/dependabot/github_actions/actions… #172
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
| # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. | |
| # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - '**.R' | |
| - '**R-CMD-check.yml' | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| name: R-CMD-check | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| jobs: | |
| R-CMD-check: | |
| runs-on: ${{ matrix.config.os }} | |
| name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - py${{ matrix.config.python-version }} - geedim ${{ matrix.config.geedim-version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - {os: macos-latest, r: 'release', geedim-version: 'latest', python-version: '3.13', authenticate: false} | |
| - {os: windows-latest, r: 'release', geedim-version: 'latest', python-version: '3.13', authenticate: false} | |
| - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release', geedim-version: 'latest', python-version: '3.14', authenticate: true} | |
| - {os: ubuntu-latest, r: 'release', geedim-version: 'latest', python-version: '3.13', authenticate: true} | |
| - {os: ubuntu-latest, r: 'release', geedim-version: '1.9.0', python-version: '3.12', authenticate: true} | |
| - {os: ubuntu-22.04, r: '3.6', geedim-version: 'latest', python-version: '3.11', authenticate: false} | |
| env: | |
| R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| GOOGLE_CLOUD_QUOTA_PROJECT: ${{ secrets.GCP_PROJECT_ID }} | |
| WIF_PROVIDER: ${{ secrets.WIF_PROVIDER }} | |
| GCP_SA_EMAIL: ${{ secrets.GCP_SA_EMAIL }} | |
| R_RGEEDIM_RUN_EXAMPLES: ${{ matrix.config.authenticate && matrix.config.r == 'devel' && 'TRUE' || 'FALSE' }} | |
| R_RGEEDIM_PYTHON_ENVNAME: "r-rgeedim" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: ${{ matrix.config.r }} | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.config.python-version }} | |
| architecture: 'x64' | |
| - uses: r-lib/actions/setup-pandoc@v2 | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install gdal | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: ${{ matrix.config.r }} | |
| http-user-agent: ${{ matrix.config.http-user-agent }} | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| extra-packages: any::rcmdcheck, rstudio/reticulate, any::remotes, local::. | |
| needs: check | |
| - name: Install Python dependencies | |
| run: | | |
| venv_path <- reticulate::virtualenv_create("r-rgeedim", version = "${{ matrix.config.python-version }}") | |
| reticulate::use_virtualenv("r-rgeedim") | |
| if (Sys.info()["sysname"] == "Windows") { | |
| python_path <- normalizePath(file.path(path.expand(venv_path), "Scripts", "python.exe")) | |
| remotes::install_github("brownag/rgeowheels") | |
| rgeowheels::set_rgeowheels_python(python_path) | |
| py_version <- reticulate::py_config()$version | |
| rgeowheels::install_wheel("gdal", pyversion = substr(py_version, 1, 4)) | |
| rgeowheels::install_wheel("rasterio", pyversion = substr(py_version, 1, 4)) | |
| } | |
| if ("${{ matrix.config.geedim-version }}" == "latest") { | |
| reticulate::virtualenv_install("r-rgeedim", "geedim") | |
| } else { | |
| reticulate::virtualenv_install("r-rgeedim", paste0("geedim==", "${{ matrix.config.geedim-version }}")) | |
| } | |
| print(reticulate::py_config()) | |
| shell: Rscript {0} | |
| - name: Authenticate to Google Cloud (WIF) | |
| if: matrix.config.authenticate == true | |
| uses: 'google-github-actions/auth@v3' | |
| with: | |
| workload_identity_provider: ${{ secrets.WIF_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SA_EMAIL }} | |
| - name: Set up Google Application Credentials for rgeedim | |
| if: matrix.config.authenticate == true | |
| run: | | |
| creds_file <- Sys.getenv("GOOGLE_APPLICATION_CREDENTIALS") | |
| if (creds_file == "" || !file.exists(creds_file)) { | |
| stop("GOOGLE_APPLICATION_CREDENTIALS not set or file does not exist") | |
| } | |
| shell: Rscript {0} | |
| - name: Authenticate with Earth Engine | |
| if: matrix.config.authenticate == true | |
| run: | | |
| rgeedim::gd_authenticate(quiet = TRUE) | |
| rgeedim::gd_initialize(quiet = FALSE) | |
| if (rgeedim::gd_is_initialized()) { | |
| cat("Earth Engine successfully initialized!\n") | |
| } else { | |
| cat("Earth Engine failed to initialize.\n") | |
| } | |
| shell: Rscript {0} | |
| - uses: r-lib/actions/check-r-package@v2 | |
| with: | |
| upload-snapshots: true | |