diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml new file mode 100644 index 0000000..4bfbf51 --- /dev/null +++ b/.github/actions/setup/action.yaml @@ -0,0 +1,11 @@ +name: Specific setup for connector +description: Starts a postgres database for unit tests +runs: + using: "composite" + steps: + - name: Start local postgres server with Docker + if: runner.os == 'Linux' + shell: bash + run: | + docker pull postgres + docker run --name my-postgres --env POSTGRES_PASSWORD=password --publish 5432:5432 --detach postgres diff --git a/.github/workflows/R-CMD-check-versions.yaml b/.github/workflows/R-CMD-check-versions.yaml deleted file mode 100644 index 4f4f50b..0000000 --- a/.github/workflows/R-CMD-check-versions.yaml +++ /dev/null @@ -1,85 +0,0 @@ ---- -on: - push: - branches: - - main - - master - pull_request: - branches: - - main - - master -permissions: read-all - -name: R-CMD-check-versions - -jobs: - R-CMD-check: - runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} (R ${{ matrix.config.r }}, ${{ matrix.config.date }}) - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - windows-latest - - ubuntu-latest - config: - - date: 2023-10-25 # 08mar2024: Next release date for SCE-R - r: 4.3.1 - env: - R_KEEP_PKG_SOURCE: yes - POSTGRES_PW: ${{secrets.TEST_POSTGRES_DB_PW}} - GITHUB_PAT: ${{ secrets.ACTION_PAT || secrets.GITHUB_TOKEN }} - - 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 }} - use-public-rspm: false - - - name: Install curl - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt install libcurl4-openssl-dev - - - name: Install dependencies - run: | - options( - repos = c(CRAN = "https://packagemanager.posit.co/cran/${{ matrix.config.date }}") - ) - - - install.packages(c("attachment", "rcmdcheck", "pak"), Ncpus = parallel::detectCores()-1) - - pak::pak_update() - - - attachment::att_from_description(field = c("Depends", "Imports", "Suggests", "Remotes")) |> - pak::pkg_install() - - shell: Rscript {0} - - - name: Session info - run: | - sessionInfo() - installed.packages()[,c("Package", "Version")] - - shell: Rscript {0} - - - name: Start local postgres server with Docker - if: runner.os == 'Linux' - run: | - docker pull postgres - docker run --name my-postgres --env POSTGRES_PASSWORD=${{env.POSTGRES_PW}} --publish 5432:5432 --detach postgres - - - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true - - - name: Stop and remove postgres server - if: runner.os == 'Linux' - run: | - docker stop my-postgres - docker remove my-postgres diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml deleted file mode 100644 index 674068f..0000000 --- a/.github/workflows/R-CMD-check.yaml +++ /dev/null @@ -1,70 +0,0 @@ ---- -# 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 -permissions: - contents: read -name: R-CMD-check -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: - R_KEEP_PKG_SOURCE: true - POSTGRES_PW: ${{secrets.TEST_POSTGRES_DB_PW}} - GITHUB_PAT: ${{ secrets.ACTION_PAT || secrets.GITHUB_TOKEN }} - - 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 - needs: check - - - name: Start local postgres server with Docker - if: runner.os == 'Linux' - run: | - docker pull postgres - docker run --name my-postgres --env POSTGRES_PASSWORD=${{env.POSTGRES_PW}} --publish 5432:5432 --detach postgres - - - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true - - - name: Stop and remove postgres server - if: runner.os == 'Linux' - run: | - docker stop my-postgres - docker remove my-postgres diff --git a/.github/workflows/check_and_co.yaml b/.github/workflows/check_and_co.yaml new file mode 100644 index 0000000..32912ed --- /dev/null +++ b/.github/workflows/check_and_co.yaml @@ -0,0 +1,39 @@ +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master +name: All actions +env: + R_KEEP_PKG_SOURCE: true + POSTGRES_PW: ${{secrets.TEST_POSTGRES_DB_PW}} +jobs: + check-current-version: + name: Check current version + uses: >- + NovoNordisk-OpenSource/r.workflows/.github/workflows/check_current_version.yaml@main + with: + use_local_setup_action: true + check-nn-version: + name: Check NN version + uses: >- + NovoNordisk-OpenSource/r.workflows/.github/workflows/check_nn_versions.yaml@main + with: + use_local_setup_action: true + pkgdown: + name: Pkgdown site + uses: NovoNordisk-OpenSource/r.workflows/.github/workflows/pkgdown.yaml@main + with: + use_local_setup_action: true + coverage: + name: Coverage report + uses: NovoNordisk-OpenSource/r.workflows/.github/workflows/coverage.yaml@main + with: + use_local_setup_action: true + megalinter: + name: Megalinter + uses: NovoNordisk-OpenSource/r.workflows/.github/workflows/megalinter.yaml@main diff --git a/.github/workflows/mega-linter.yaml b/.github/workflows/mega-linter.yaml deleted file mode 100644 index 5084601..0000000 --- a/.github/workflows/mega-linter.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# MegaLinter GitHub Action configuration file -# More info at https://megalinter.io -# Modified from: https://megalinter.io/latest/install-github/ - -name: MegaLinter - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -permissions: - contents: write - issues: write - pull-requests: write - -env: - ADDITIONAL_EXCLUDED_DIRECTORIES: "dev" - APPLY_FIXES: all - APPLY_FIXES_EVENT: pull_request - APPLY_FIXES_MODE: pull_request - KICS_EXCLUDE_QUERIES: 555ab8f9-2001-455e-a077-f2d0f41e2fb9 # See queries: https://docs.kics.io/latest/queries/all-queries/ - SPELL_LYCHEE_FILE_EXTENSIONS: '*' # Check all file types for dead links - SPELL_LYCHEE_FILTER_REGEX_EXCLUDE: "R-CMD-check-versions.yaml" - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - megalinter: - name: MegaLinter - runs-on: ubuntu-latest - - steps: - - name: Set up node.js 20 - uses: actions/setup-node@v3 - with: - node-version: '20' - - - name: Checkout Code - uses: actions/checkout@v3 - with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances - - - name: MegaLinter - id: ml - uses: oxsecurity/megalinter@v7 - env: - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Archive production artifacts - if: success() || failure() - uses: actions/upload-artifact@v4 - with: - name: MegaLinter reports - path: | - megalinter-reports - mega-linter.log - - - name: Create Pull Request with applied fixes - id: cpr - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - commit-message: "[MegaLinter] Apply linters automatic fixes" - title: "[MegaLinter] Apply linters automatic fixes" - labels: bot - - - name: Create PR output - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" - - - name: Prepare commit - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: sudo chown -Rc $UID .git/ - - - name: Commit and push applied linter fixes - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} - commit_message: "[MegaLinter] Apply linters fixes" - commit_user_name: megalinter-bot - commit_user_email: nicolas.vuillamy@ox.security diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml deleted file mode 100644 index 7f0d157..0000000 --- a/.github/workflows/pkgdown.yaml +++ /dev/null @@ -1,87 +0,0 @@ -# Workflow adjusted from usethis::use_pkgdown_github_pages() to also publish pages from PRs in a subfolder - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - release: - types: [published] - workflow_dispatch: - -permissions: - contents: write - pull-requests: write - -name: pkgdown - -jobs: - pkgdown: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.ACTION_PAT || secrets.GITHUB_TOKEN }} - # Only restrict concurrency for non-PR jobs - concurrency: - group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::pkgdown, local::. - needs: website - - - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) - shell: Rscript {0} - - # If not pull request a brand new webpage is deployed - - - name: Deploy to GitHub pages 🚀 - if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.5.0 - with: - clean: false - branch: gh-pages - folder: docs - - # If pull request the webpage is deployed inside a dev/"PR number" folder for review - - - name: Add pkgdown PR Comment - uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' - with: - recreate: true - header: pkgdown - message: | - # Github pages - Review the pkgdown webpage for the PR [here](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/dev/${{ github.event.pull_request.number }}) - - - name: Copy page to temp folder - if: github.event_name == 'pull_request' - run: | - mkdir -p /home/runner/work/dev - cp -r ./docs/* /home/runner/work/dev - - - name: Check out gh-pages branch - if: github.event_name == 'pull_request' - uses: actions/checkout@v4 - with: - ref: gh-pages - - - name: Copy and push to gh-pages - if: github.event_name == 'pull_request' - run: | - mkdir -p dev/${{ github.event.pull_request.number }} - cp -r /home/runner/work/dev/* ./dev/${{ github.event.pull_request.number }} - git config --global user.email "actions-robot@novonordisk.com" - git config --global user.name "Actions Robot From Github Actions" - git add . - git commit -m "Update gh pages from the PR" - git push diff --git a/.github/workflows/test-coverage-internal.yaml b/.github/workflows/test-coverage-internal.yaml deleted file mode 100644 index b003608..0000000 --- a/.github/workflows/test-coverage-internal.yaml +++ /dev/null @@ -1,84 +0,0 @@ ---- -# Workflow adjusted from usethis::use_github_action("test-coverage") to just report coverage internally and not to publish to codecov - -on: - push: - branches: - - main - - master - pull_request: - branches: - - main - - master -permissions: - contents: read - pull-requests: write -name: test-coverage-internal -jobs: - test-coverage-internal: - runs-on: ubuntu-latest - env: - POSTGRES_PW: ${{secrets.TEST_POSTGRES_DB_PW}} - GITHUB_PAT: ${{ secrets.ACTION_PAT || secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: | - any::covr - any::xml2 - any::dplyr - any::knitr - needs: coverage - - - name: Start local postgres server with Docker - run: | - docker pull postgres - docker run --name my-postgres --env POSTGRES_PASSWORD=${{env.POSTGRES_PW}} --publish 5432:5432 --detach postgres - - - name: Test coverage - run: | - covr::package_coverage() |> - covr::to_cobertura(filename = "cobertura.xml") - - xml <- xml2::read_xml("cobertura.xml") - - pkg_cov <- xml |> - xml2::xml_find_first("packages/package") |> - xml2::xml_attrs() |> - dplyr::bind_rows() - - fnc_cov <- xml |> - xml2::xml_find_first("packages/package") |> - xml2::xml_find_all("classes/class") |> - xml2::xml_attrs() |> - lapply(dplyr::bind_rows) - - res <- list(pkg_cov, fnc_cov) |> - dplyr::bind_rows() |> - dplyr::transmute( - Name = dplyr::coalesce(filename, name), - `Coverage (%)` = round(as.numeric(`line-rate`)*100, digits = 2) - ) |> - knitr::kable() - - c("# Code coverage", res) |> - writeLines(con = "coverage.md") - shell: Rscript {0} - - - name: Stop and remove postgres server - run: | - docker stop my-postgres - docker remove my-postgres - - - name: Add Coverage PR Comment - uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' - with: - recreate: true - header: coverage - path: coverage.md diff --git a/DESCRIPTION b/DESCRIPTION index cf65929..d206704 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,7 +10,7 @@ Description: The connector package helps connecting R to databases that contains ADAM, STDM and so on. The package defines an interface that can be reuse for any databases. License: Apache License (>= 2) -URL: https://jubilant-adventure-yr95p3g.pages.github.io/ +URL: https://novonordisk-opensource.github.io/connector, https://github.com/novonordisk-opensource/connector Imports: arrow, checkmate, @@ -49,4 +49,4 @@ Roxygen: list(markdown = TRUE, r6 = TRUE) RoxygenNote: 7.3.2 Remotes: NovoNordisk-OpenSource/zephyr, - NN-OpenSource/connector.logger + NovoNordisk-OpenSource/connector.logger diff --git a/NEWS.md b/NEWS.md index bd44292..5b29b28 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,6 @@ * Added `connectors` super class -# NNaccess 0.0.1 +# connector 0.0.1 -* Initial release to internal package manager +* Initial version diff --git a/_pkgdown.yml b/_pkgdown.yml index 1b23ce2..e643646 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,4 @@ -url: https://fantastic-adventure-gqozn9k.pages.github.io/ +url: https://novonordisk-opensource.github.io/connector template: bootstrap: 5 reference: diff --git a/tests/testthat/test-dbi.R b/tests/testthat/test-dbi.R index f5a9b2e..90b964f 100644 --- a/tests/testthat/test-dbi.R +++ b/tests/testthat/test-dbi.R @@ -15,7 +15,7 @@ specs <- list( drv = RPostgres::Postgres(), dbname = "postgres", user = "postgres", - password = Sys.getenv("POSTGRES_PW"), # Stored in GH actions + password = "password", # Sys.getenv("POSTGRES_PW"), # Stored in GH actions port = 5432, host = "localhost" )