Skip to content

Commit

Permalink
Merge pull request #65 from Rapporteket/db-unittest
Browse files Browse the repository at this point in the history
run db unit tests github actions, ubuntu only
  • Loading branch information
areedv authored Mar 11, 2021
2 parents d2c5d4f + 865e92b commit d61f46e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ jobs:

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

- name: Db unit tests in ubuntu/linux only
if: runner.os != 'Windows'
run: |
if [[ ${{ runner.os }} == Linux ]]; then
echo "GITHUB_ACTIONS_RUN_DB_UNIT_TESTS=true" >> $GITHUB_ENV
else
echo "GITHUB_ACTIONS_RUN_DB_UNIT_TESTS=false" >> $GITHUB_ENV
fi
- name: Set up MySQL, ubuntu only
if: runner.os == 'Linux'
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE IF NOT EXISTS rapbase; USE rapbase; CREATE TABLE testTable (id INT, someText VARCHAR(50), someInt INT, someFloat DOUBLE, someTime DATETIME);' -uroot -proot
- name: Query dependencies
run: |
install.packages('remotes')
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ jobs:
runs-on: ubuntu-20.04
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTIONS_RUN_DB_UNIT_TESTS: true
steps:
- uses: actions/checkout@v2

- name: Install unmet sys deps
run: |
sudo apt update
sudo apt install -y --no-install-recommends libcurl4-openssl-dev libgit2-dev
- name: Set up MySQL for unit testing
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE IF NOT EXISTS rapbase; USE rapbase; CREATE TABLE testTable (id INT, someText VARCHAR(50), someInt INT, someFloat DOUBLE, someTime DATETIME);' -uroot -proot
- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-pandoc@v1
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rapbase
Type: Package
Title: Base Functions and Resources for Rapporteket
Version: 1.13.0
Version: 1.13.1
Authors@R: c(
person(given = "Are",
family = "Edvardsen",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rapbase 1.13.1

* Included unit tests and coverage reporting depending on a test database during github actions (ci)

# rapbase 1.13.0

* New function providing registry db metadata
Expand Down
4 changes: 2 additions & 2 deletions inst/dbConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ nordummy:
rapbase:
host : 127.0.0.1
name : rapbase
user : travis
pass :
user : root
pass : root
disp : ForTestingOnly

# for testing, in rap-dev-data container
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-dbConnection.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ context("Handling db connections")
checkDb <- function() {
if (Sys.getenv("R_RAP_INSTANCE") == "DEV") {
NULL
} else if (Sys.getenv("TRAVIS") == "true") {
} else if (Sys.getenv("GITHUB_ACTIONS_RUN_DB_UNIT_TESTS") == "true") {
NULL
} else {
testthat::skip("Test skipped due to lack of database infrastructure")
Expand Down

0 comments on commit d61f46e

Please sign in to comment.