Update Pipeline Config and Fix Unit Test Execution in GitHub Actions (#97)

* Update pipeline with latest r-lib actions.

* Update readme to include build status GHA

* force upated testthat package to >= 2.0.1

* remove snapshot reference.

* new cache

* Fix cause of Invalid Cursor State

* Add fix for failing tests in CI

* Remove commented code in ci yaml
This commit is contained in:
Sean Leonard 2022-02-25 12:18:10 -08:00 коммит произвёл GitHub
Родитель f4b84b6769
Коммит f27e8f1495
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 34 добавлений и 50 удалений

31
.github/workflows/ci.yaml поставляемый
Просмотреть файл

@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
r-version: [3.5]
r-version: ["3.5.2"]
env:
# Define CI to skip some test case.
@ -43,22 +43,25 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v1
- name: Set up R ${{ matrix.r-version }} Runtime
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
extra-repositories: 'https://mran.microsoft.com/snapshot/2019-02-01'
- name: Install dependencies
working-directory: ./R
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Check
working-directory: ./R
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}
- name: Install R Package Dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: 2
working-directory: ./R
extra-packages:
#Retrieves most recent odbc pkg from cran to avoid errors seen in older versions.
#Updated odbc pkg is still compatible with R >= 3.2.0
cran::odbc
rcmdcheck
- uses: r-lib/actions/check-r-package@v2
with:
working-directory: ./R
Python:
runs-on: windows-latest

Просмотреть файл

@ -449,7 +449,7 @@ sqlRemoteExecuteFun <- function(connection, FUN, ..., useRemoteFun = FALSE, asus
withCallingHandlers({
binArgList <- unlist(lapply(lapply(strsplit(\"%s\",\";\")[[1]], as.hexmode), as.raw))
argList <- as.list(unserialize(binArgList))
result <- do.call(%s, argList)
result <- suppressPackageStartupMessages(do.call(%s, argList))
},
error = function(err)
{
@ -458,6 +458,7 @@ sqlRemoteExecuteFun <- function(connection, FUN, ..., useRemoteFun = FALSE, asus
warning = function(warn)
{
funwarnings <<- c(funwarnings, warn$message)
invokeRestart(\"muffleWarning\")
}
), silent = TRUE
))
@ -543,6 +544,11 @@ sqlRemoteExecuteFun <- function(connection, FUN, ..., useRemoteFun = FALSE, asus
funwarnings <-lst[[3]]
output <- lst[[4]]
if (is.null(result))
{
result <- FALSE
}
if (!is.null(output))
{
for(o in output)

Просмотреть файл

@ -51,7 +51,7 @@ testthatDir <- getwd()
R_Root <- file.path(testthatDir, "../..")
scriptDirectory <- file.path(testthatDir, "scripts")
options(repos = c(CRAN="https://cran.microsoft.com", CRANextra = "http://www.stats.ox.ac.uk/pub/RWin"))
options(repos = c(CRAN="https://cran.microsoft.com", CRANextra = "https://mran.microsoft.com/snapshot/2019-02-01"))
cat("INFO: repos = ", getOption("repos"), sep="\n")
# Compute context specifications

Просмотреть файл

@ -8,10 +8,6 @@ context("Tests for sqlmlutils package management")
test_that( "successfull install and remove of package with special char in name that requires [] in t-sql",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
#
# Set scope to public for trusted connection on Windows
#

Просмотреть файл

@ -8,10 +8,6 @@ context("Tests for sqlmlutils package management create external library")
test_that("Package APIs interop with Create External Library",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
cat("\nINFO: test if package management interops properly with packages installed directly with CREATE EXTERNAL LIBRARY\n
Note:\n
packages installed with CREATE EXTERNAL LIBRARY won't have top-level attribute set in extended properties\n

Просмотреть файл

@ -8,10 +8,6 @@ context("Tests for sqlmlutils package management dependencies")
test_that("single package install and removal with no dependencies",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
#
# Set scope to public for trusted connection on Windows
#
@ -66,10 +62,6 @@ test_that("single package install and removal with no dependencies",
test_that( "package install and uninstall with dependency",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
connectionStringAirlineUserdbowner <- helper_getSetting("connectionStringAirlineUserdbowner")
scope <- "private"

Просмотреть файл

@ -8,10 +8,6 @@ context("Tests for sqlmlutils package management scope")
test_that("dbo cannot install package into private scope",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
skip_if(helper_isServerLinux(), "Linux tests do not have support for Trusted user." )
connectionStringDBO <- helper_getSetting("connectionStringDBO")

Просмотреть файл

@ -8,10 +8,6 @@ context("Tests for sqlmlutils package management top level")
test_that("package top level install and remove",
{
# There is an issue running this test in github actions CI environment.
# We will need to investigate why it failed. For now, we will disable the test in CI.
skip_on_ci()
connectionStringAirlineUserdbowner <- helper_getSetting("connectionStringAirlineUserdbowner")
scope <- "private"

Просмотреть файл

@ -90,7 +90,7 @@ test_that("Simple InputDataSet test",
capture.output(createSprocFromFunction(name, inData, connectionString = connection, inputParams = inputParams))
expect_true(checkSproc(name, connectionString = connection))
res <- executeSproc(name, in_df = "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", connectionString = connection)
res <- executeSproc(name, in_df = "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", connectionString = connection)
expect_equal(nrow(res), 10)
expect_equal(ncol(res), 4)
@ -119,7 +119,7 @@ test_that("InputDataSet to OutputDataSet test",
capture.output(createSprocFromFunction(name, inOutData, connectionString = connection, inputParams = inputParams, outputParams = outputParams))
expect_true(checkSproc(name, connectionString = connection))
res <- executeSproc(name, in_df = "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", connectionString = connection)
res <- executeSproc(name, in_df = "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", connectionString = connection)
expect_equal(nrow(res), 10)
expect_equal(ncol(res), 4)
@ -146,12 +146,12 @@ test_that("InputDataSet with InputParameter test",
capture.output(createSprocFromFunction(name, inDataParams, connectionString = connection, inputParams = inputParams))
expect_true(checkSproc(name, connectionString = connection))
res <- executeSproc(name, id = "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", ip = 4, connectionString = connection)
res <- executeSproc(name, id = "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", ip = 4, connectionString = connection)
expect_equal(nrow(res), 11)
expect_equal(ncol(res), 4)
expect_error(executeSproc(name, "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", ip = 4, connectionString = connection))
expect_error(executeSproc(name, "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", ip = 4, connectionString = connection))
dropIfExists(name, connectionString = connection)
expect_false(checkSproc(name, connectionString = connection))
@ -177,12 +177,12 @@ test_that("InputDataSet with InputParameter test, out of order",
capture.output(createSprocFromFunction(name, inDataParams, connectionString = connection, inputParams = inputParams))
expect_true(checkSproc(name, connectionString = connection))
res <- executeSproc(name, ip2 = "Hello", ip = 4, id = "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", connectionString = connection)
res <- executeSproc(name, ip2 = "Hello", ip = 4, id = "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", connectionString = connection)
expect_equal(nrow(res), 11)
expect_equal(ncol(res), 4)
expect_error(executeSproc(name,ip = 4, "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000", connectionString = connection))
expect_error(executeSproc(name,ip = 4, "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000", connectionString = connection))
dropIfExists(name, connectionString = connection)
expect_false(checkSproc(name, connectionString = connection))
@ -205,7 +205,7 @@ test_that("Stored Procedure with Scripts",
connectionString = connection, name=name, file.path(scriptDir, "script3.R"), inputParams = inputParams, outputParams = outputParams))
expect_true(checkSproc(connectionString = connection, name = name))
retVal <- executeSproc(connectionString = connection, name, num1 = 3, num2 = 4, in_df = "SELECT TOP 10 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000")
retVal <- executeSproc(connectionString = connection, name, num1 = 3, num2 = 4, in_df = "SELECT TOP 10 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000")
expect_equal(nrow(retVal), 11)
expect_equal(ncol(retVal), 4)
@ -333,7 +333,7 @@ test_that("Bad input param types or usage",
expect_true(checkSproc(connection, name))
expect_error(expect_warning(executeSproc(connection, name, arg1=12314532)))
res <- executeSproc(connection, name, arg1="SELECT TOP 5 Id, CarrierDelay, TailNum, CancellationCode FROM airline5000")
res <- executeSproc(connection, name, arg1="SELECT TOP 5 Id, CarrierDelay, FlightNum, ActualElapsedTime FROM airline5000")
expect_equal(ncol(res), 4)
expect_equal(nrow(res), 5)

Просмотреть файл

@ -1,7 +1,6 @@
# sqlmlutils
[![Build Status](https://travis-ci.com/Microsoft/sqlmlutils.svg?branch=master)](https://travis-ci.com/Microsoft/sqlmlutils)
![Github action CI](https://github.com/Microsoft/sqlmlutils/actions/workflows/main.yml/badge.svg)
[![BuildAndTest](https://github.com/microsoft/sqlmlutils/actions/workflows/ci.yaml/badge.svg)](https://github.com/microsoft/sqlmlutils/actions/workflows/ci.yaml)
sqlmlutils is a package designed to help users interact with SQL databases (SQL Server and Azure SQL Database) and execute R or Python code in SQL from an R/Python client.
Currently, only the R version of sqlmlutils is supported in Azure SQL Database. Python support will be added later.