Skip to content
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

Setup GitHub actions cmd check and code coverage #14

Merged
merged 24 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cdbc83f
added the github actions - CMD check and code coverage
SunnyTseng Aug 12, 2024
db98f09
set up CMD check and modified the yaml to load Python
SunnyTseng Aug 13, 2024
dfec69d
fixed failed tests - load required python version and rbirdnet module
SunnyTseng Aug 14, 2024
be2d6f7
updated the helper in test, only run test when the r-birdnet is setup
SunnyTseng Aug 14, 2024
1ef579d
update the CMD check ymal
SunnyTseng Aug 14, 2024
dc9cfd6
remove the code coverage github action for simplicity
SunnyTseng Aug 14, 2024
67a0a08
load birdnetR python module while running test on Github Action
SunnyTseng Aug 14, 2024
42b3770
remove the use of devtools::load_all()
SunnyTseng Aug 14, 2024
92c5774
Update helper.R
SunnyTseng Aug 15, 2024
7de10e6
Update R-CMD-check.yaml
SunnyTseng Aug 21, 2024
6b53e1b
edited the installed python packages
SunnyTseng Aug 21, 2024
41212bc
fixed the extra quotation
SunnyTseng Aug 21, 2024
e5370c1
changed the virtualenv to the same name r-birdnet
SunnyTseng Aug 21, 2024
030139e
removed the codes for appending text into files
SunnyTseng Aug 21, 2024
bcb15d4
try setting up birdnet for the CMD check in github action
SunnyTseng Aug 21, 2024
791f4a0
Updated CMD check for the Github Action
SunnyTseng Aug 21, 2024
4f81eb6
try setting up BirdNET on the environment
SunnyTseng Aug 21, 2024
e7fd548
Update R-CMD-check.yaml
SunnyTseng Aug 21, 2024
93dd6a5
updated the workflow file
SunnyTseng Aug 21, 2024
f2e0f87
Merge branch 'main' into setup-github-actions---CMD-check-and-code-co…
fegue Sep 17, 2024
b36d9bf
removed the helper in the testthat folder
SunnyTseng Oct 3, 2024
64319af
edited the cmd check workflow
SunnyTseng Oct 3, 2024
64c6132
added back installing python back to the setup r-birdnet section
SunnyTseng Oct 3, 2024
2de89c4
removed the setup-python section
SunnyTseng Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# 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, master]
pull_request:
branches: [main, master]
workflow_dispatch:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-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 }}
R_KEEP_PKG_SOURCE: yes

steps:

- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- 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 reticulate
needs: check

- uses: actions/setup-python@v4
with:
python-version: "3.11"

# - name: setup r-birdnet venv
# shell: Rscript {0}
# run: |

# path_to_python <- reticulate::virtualenv_create(
# envname = "r-birdnet",
# python = Sys.which("python"), # placed on PATH by the setup-python action
# packages = c(
# "numpy", "pandas"
# )
# )

# writeLines(sprintf("RETICULATE_PYTHON=%s", path_to_python),
# Sys.getenv("GITHUB_ENV"))


- name: setup r-birdnet venv and install birdnet
shell: Rscript {0}
run: |

reticulate::install_python("3.11")
fegue marked this conversation as resolved.
Show resolved Hide resolved
reticulate::virtualenv_create(envname = "r-birdnet",
version = "3.11")
reticulate::use_virtualenv("r-birdnet")
fegue marked this conversation as resolved.
Show resolved Hide resolved

install.packages("devtools")
fegue marked this conversation as resolved.
Show resolved Hide resolved
library(devtools)
devtools::load_all()
birdnetR::install_birdnet()


- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

2 changes: 1 addition & 1 deletion R/birdnet_interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ py_builtins <- NULL

# Use superassignment to update global reference to the Python packages
py_birdnet_models <<- reticulate::import("birdnet.models",
delay_load = list(before_load = .check_birdnet_version())
delay_load = list(before_load = function() .check_birdnet_version())
fegue marked this conversation as resolved.
Show resolved Hide resolved
)
py_birdnet_utils <<- reticulate::import("birdnet.utils", delay_load = TRUE)
py_birdnet_audio_based_prediction <<- reticulate::import("birdnet.audio_based_prediction", delay_load = TRUE)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/birdnet-team/birdnetR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/birdnet-team/birdnetR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

This is a wrapper for the `birdnet` Python package for automated bird sound ID available [here](https://github.com/birdnet-team/birdnet).
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/helper.R
fegue marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Check that the required versions of Python and
# the Python 'birdnet' module are installed; if not,
# either print a message for the user instructing
# them to install those, or see if we can do it
# automatically. Can use .check_birdnet_version()

# Make sure reticulate uses the 'r-birdnet'
# virtual environment when running tests.
library(reticulate)
reticulate::use_virtualenv("r-birdnet", required = TRUE)

# make sure birdnet Python modules are installed
birdnetR::install_birdnet()
Loading