diff --git a/.github/workflows/Check-package.yaml b/.github/workflows/Check-package.yaml new file mode 100644 index 0000000..dc84064 --- /dev/null +++ b/.github/workflows/Check-package.yaml @@ -0,0 +1,16 @@ +on: + push: + branches: [main, stage, dev] + pull_request: + branches: [main, stage, dev] + workflow_dispatch: + +name: Check Package ๐Ÿ“ฆ + +jobs: + check: + name: Checks (from ramnog) + uses: hta-pharma/ramnog/.github/workflows/Check-package.yaml@feature/workflows_final + + + diff --git a/.github/workflows/Check.yaml b/.github/workflows/Check.yaml deleted file mode 100644 index 1ec608f..0000000 --- a/.github/workflows/Check.yaml +++ /dev/null @@ -1,47 +0,0 @@ - - - -on: - push: - branches: [main, stage, dev] - pull_request: - branches: [main, stage, dev] - workflow_dispatch: - -name: Check - -jobs: - audit: - name: Audit Dependencies ๐Ÿ•ต๏ธโ€โ™‚๏ธ - uses: insightsengineering/r.pkg.template/.github/workflows/audit.yaml@main - - licenses: - name: License Check ๐Ÿƒ - uses: insightsengineering/r.pkg.template/.github/workflows/licenses.yaml@main - - check-reuse: - name: RMD check ๐Ÿ“ฆ - uses: ./.github/workflows/R-CMD-check.yaml - - test: - name: Test ๐Ÿงช - uses: ./.github/workflows/Test.yaml - - gitleaks: - name: gitleaks ๐Ÿ’ง - uses: insightsengineering/r.pkg.template/.github/workflows/gitleaks.yaml@main - with: - check-for-pii: true - - vbump: - name: Version Bump ๐Ÿคœ๐Ÿค› - if: github.event_name == 'push' && github.ref != 'refs/heads/main' - uses: insightsengineering/r.pkg.template/.github/workflows/version-bump.yaml@main - secrets: - REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # roxygen: - # name: Roxygen ๐Ÿ“ฆ - # uses: ./.github/workflows/Roxygen.yaml - - diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml deleted file mode 100644 index 63c5e50..0000000 --- a/.github/workflows/R-CMD-check.yaml +++ /dev/null @@ -1,50 +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: - workflow_call: - -name: R-CMD-check - -# concurrency: -# group: roxygen-${{ github.event.pull_request.number || github.ref }} -# cancel-in-progress: true - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: ubuntu-latest, r: 'release'} - # - {os: ubuntu-latest, r: 'oldrel-1'} - # - {os: ubuntu-latest, r: 'oldrel-2'} - # - {os: ubuntu-latest, r: 'oldrel-3'} - # - {os: ubuntu-latest, r: 'oldrel-4'} - - 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 - needs: check - - - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true diff --git a/.github/workflows/Release-package.yaml b/.github/workflows/Release-package.yaml new file mode 100644 index 0000000..195617d --- /dev/null +++ b/.github/workflows/Release-package.yaml @@ -0,0 +1,16 @@ +on: + push: + branches: [main, stage, dev] + pull_request: + branches: [main, stage, dev] + workflow_dispatch: + +name: Check Package ๐Ÿ“ฆ + +jobs: + check: + name: Release (from ramnog) + uses: hta-pharma/ramnog/.github/workflows/Release-package.yaml@feature/workflows_final + + + diff --git a/.github/workflows/Roxygen.yaml b/.github/workflows/Roxygen.yaml deleted file mode 100644 index 8c904eb..0000000 --- a/.github/workflows/Roxygen.yaml +++ /dev/null @@ -1,180 +0,0 @@ ---- - name: Roxygen ๐Ÿ…พ - - on: - workflow_call: - inputs: - # install-system-dependencies: - # description: Check for and install system dependencies - # required: false - # default: false - # type: boolean - # enable-staged-dependencies-check: - # description: Enable staged dependencies YAML check - # required: false - # default: false - # type: boolean - auto-update: - description: If man pages are not up-to-date, they will be automatically updated and committed back to the branch. - required: false - default: false - type: boolean - # sd-direction: - # description: The direction to use to install staged dependencies. Choose between 'upstream', 'downstream' and 'all' - # required: false - # type: string - # default: upstream - package-subdirectory: - description: Subdirectory in the repository, where the R package is located. - required: false - type: string - default: "." - secrets: - REPO_GITHUB_TOKEN: - description: | - Github token with read access to repositories, required for staged.dependencies installation - required: false - - # concurrency: - # group: roxygen-${{ github.event.pull_request.number || github.ref }} - # cancel-in-progress: true - - jobs: - roxygen: - name: Manual pages check ๐Ÿ - runs-on: ubuntu-latest - if: > - !contains(github.event.commits[0].message, '[skip roxygen]') - && github.event.pull_request.draft == false - container: - image: ghcr.io/insightsengineering/rstudio:latest - - steps: - - name: Setup token ๐Ÿ”‘ - id: github-token - run: | - if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then - echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN." - echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT - else - echo "Using REPO_GITHUB_TOKEN." - echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT - fi - shell: bash - - - name: Get branch names ๐ŸŒฟ - id: branch-name - uses: tj-actions/branch-names@v7 - - - name: Checkout repo (PR) ๐Ÿ›Ž - uses: actions/checkout@v4 - if: github.event_name == 'pull_request' - # with: - # ref: ${{ steps.branch-name.outputs.head_ref_branch }} - # path: ${{ github.event.repository.name }} - # repository: ${{ github.event.pull_request.head.repo.full_name }} - # token: ${{ steps.github-token.outputs.token }} - - - name: Checkout repo ๐Ÿ›Ž - uses: actions/checkout@v4 - if: github.event_name != 'pull_request' - # with: - # ref: ${{ steps.branch-name.outputs.head_ref_branch }} - # path: ${{ github.event.repository.name }} - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - name: Setup R dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::roxygen2 - - # - name: Restore SD cache ๐Ÿ’ฐ - # uses: actions/cache@v4 - # with: - # key: sd-${{ runner.os }}-${{ github.event.repository.name }} - # path: ~/.staged.dependencies - - # - name: Run Staged dependencies ๐ŸŽฆ - # uses: insightsengineering/staged-dependencies-action@v1 - # env: - # GITHUB_PAT: ${{ steps.github-token.outputs.token }} - # with: - # path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - # enable-check: ${{ inputs.enable-staged-dependencies-check }} - # run-system-dependencies: ${{ inputs.install-system-dependencies }} - # direction: ${{ inputs.sd-direction }} - - - name: Generate man pages ๐Ÿ“„ - run: | - logfile <- "roxygen_${{ github.event.repository.name }}.log" - con <- file(logfile) - sink(con, append = TRUE, split = TRUE) - sink(con, append = TRUE, type = "message") - roxygen2::roxygenize('.') - sink() - sink(type = "message") - logs <- readLines(logfile) - cat("๐Ÿชต Log output of 'roxygen2::roxygenize()':\n") - system2("cat", logfile) - error_marker <- grep("Error:", logs) - warnings_marker <- grep("Warning message", logs) - if (length(warnings_marker) > 0) { - cat("โš  One or more warnings were generated during the roxygen build:\n") - cat(logs[warnings_marker[[1]]:length(logs)], sep = "\n") - stop("Please ๐Ÿ™ fix the warnings shown below this message ๐Ÿ‘‡") - } - if (length(error_marker) > 0) { - cat("โ˜  One or more errors were generated during the roxygen build:\n") - cat(logs[error_marker[[1]]:length(logs)], sep = "\n") - stop("Please ๐Ÿ™ fix the errors shown below this message ๐Ÿ‘‡") - } - shell: Rscript {0} - working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - - - name: Roxygen check ๐Ÿ…พ - run: | - AUTO_UPDATE=${{ inputs.auto-update }} - if [[ -n `git status -s | grep -E "man|DESCRIPTION"` ]] - then { - ROXYGEN_VERSION="$(Rscript -e 'packageVersion("roxygen2")' | awk '{print $NF}')" - echo "๐Ÿ™ˆ Manuals are not up-to-date with roxygen comments!" - echo "๐Ÿ”€ The following differences were noted:" - git diff man/* DESCRIPTION - # Attempt to commit and push man-page updates - if [ "${AUTO_UPDATE}" == "true" ] - then { - echo "Regenerating man pages via auto-update" - git config --global user.name "github-actions" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config pull.rebase false - BRANCH_NAME="${{ steps.branch-name.outputs.head_ref_branch }}" - git pull origin ${BRANCH_NAME} || true - git add -A man/ DESCRIPTION - git commit -m "[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update" - git push -v origin HEAD:${BRANCH_NAME} || \ - (echo "โš ๏ธ Could not push to ${BRANCH_NAME} on $(git remote -v show -n origin | grep Push)" && \ - AUTO_UPDATE=failed) - } - fi - # If auto-update is disabled or is unsuccessful, let 'em know to fix manually - if [ "${AUTO_UPDATE}" != "true" ] - then { - echo -e "\n๐Ÿ’ป Please rerun the following command on your workstation and push your changes" - echo "--------------------------------------------------------------------" - echo "roxygen2::roxygenize('.')" - echo "--------------------------------------------------------------------" - echo "โ„น roxygen2 version that was used in this workflow: $ROXYGEN_VERSION" - echo "๐Ÿ™ Please ensure that the 'RoxygenNote' field in the DESCRIPTION file matches this version" - exit 1 - } - fi - } else { - echo "๐Ÿ’š Manuals are up-to-date with roxygen comments" - } - fi - shell: bash - working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} diff --git a/.github/workflows/Test.yaml b/.github/workflows/Test.yaml deleted file mode 100644 index 0582c73..0000000 --- a/.github/workflows/Test.yaml +++ /dev/null @@ -1,51 +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: - workflow_call: - -name: test-coverage - -# concurrency: -# group: roxygen-${{ github.event.pull_request.number || github.ref }} -# cancel-in-progress: true - -jobs: - test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_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 - needs: coverage - - - name: Test coverage - run: | - covr::codecov( - quiet = FALSE, - clean = FALSE, - install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") - ) - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: | - ## -------------------------------------------------------------------- - find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload test results - if: failure() - uses: actions/upload-artifact@v4 - with: - name: coverage-test-failures - path: ${{ runner.temp }}/package diff --git a/.github/workflows/fast-forward.yaml b/.github/workflows/fast-forward.yaml index 59a374c..cb36fa2 100644 --- a/.github/workflows/fast-forward.yaml +++ b/.github/workflows/fast-forward.yaml @@ -1,22 +1,22 @@ - name: Fast Forward PR - on: - issue_comment: - types: [created] - - jobs: - fast_forward_job: - name: Fast Forward - if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/fast-forward') - runs-on: ubuntu-latest - steps: - # To use this repository's private action, you must check out the repository - - name: Checkout - uses: actions/checkout@v2 - # Basic use case example - - name: Fast Forward PR - id: ff-action - uses: endre-spotlab/fast-forward-js-action@2.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - success_message: 'Success! Fast forwarded ***target_base*** to ***source_head***! ```git checkout target_base && git merge source_head --ff-only``` ' - failure_message: 'Failed! Cannot do fast forward! - try merging the target back into source first.' \ No newline at end of file +name: Fast Forward PR +on: + issue_comment: + types: [created] + +jobs: + fast_forward_job: + name: Fast Forward + if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/fast-forward') + runs-on: ubuntu-latest + steps: + # To use this repository's private action, you must check out the repository + - name: Checkout + uses: actions/checkout@v2 + # Basic use case example + - name: Fast Forward PR + id: ff-action + uses: endre-spotlab/fast-forward-js-action@2.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + success_message: 'Success! Fast forwarded ***target_base*** to ***source_head***! ```git checkout target_base && git merge source_head --ff-only``` ' + failure_message: 'Failed! Cannot do fast forward! - try merging the target back into source first.' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml deleted file mode 100644 index a7276e8..0000000 --- a/.github/workflows/pkgdown.yaml +++ /dev/null @@ -1,48 +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] - release: - types: [published] - workflow_dispatch: - -name: pkgdown - -jobs: - pkgdown: - runs-on: ubuntu-latest - # Only restrict concurrency for non-PR jobs - concurrency: - group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - permissions: - contents: write - 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} - - - 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e02cb2..82b6c2c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,76 +1,5 @@ -# All available hooks: https://pre-commit.com/hooks.html -# R specific hooks: https://github.com/lorenzwalthert/precommit repos: -- repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9027 - hooks: - # - id: style-files - # args: [--style_pkg=styler, --style_fun=tidyverse_style] - # - id: roxygenize - # codemeta must be above use-tidy-description when both are used - # - id: codemeta-description-updated - # - id: use-tidy-description - # - id: spell-check - # exclude: > - # (?x)^( - # .*\.[rR]| - # .*\.feather| - # .*\.jpeg| - # .*\.pdf| - # .*\.png| - # .*\.py| - # .*\.RData| - # .*\.rds| - # .*\.Rds| - # .*\.Rproj| - # .*\.sh| - # (.*/|)\.gitignore| - # (.*/|)\.gitlab-ci\.yml| - # (.*/|)\.lintr| - # (.*/|)\.pre-commit-.*| - # (.*/|)\.Rbuildignore| - # (.*/|)\.Renviron| - # (.*/|)\.Rprofile| - # (.*/|)\.travis\.yml| - # (.*/|)appveyor\.yml| - # (.*/|)NAMESPACE| - # (.*/|)renv/settings\.dcf| - # (.*/|)renv\.lock| - # (.*/|)WORDLIST| - # \.github/workflows/.*| - # data/.*| - # )$ - # - id: lintr - - id: readme-rmd-rendered - - id: parsable-R - - id: no-browser-statement - - id: no-print-statement - - id: no-debug-statement - exclude: "R/try_and_validate.R" - - id: deps-in-desc - args: [--allow_private_imports] - exclude: "tests/testthat/test-fetch_db_data.R" - - id: pkgdown -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.2.3 - hooks: - - id: no-commit-to-branch - args: [--branch, staging, --branch, main, --branch, dev] - - id: check-added-large-files - args: ['--maxkb=200'] - # - id: file-contents-sorter - # files: '^\.Rbuildignore$' - # - id: end-of-file-fixer - # exclude: > - # \.Rd| - # tests/testthat/_snaps/* - - id: detect-private-key - # - id: detect-aws-credentials -- repo: local +- repo: https://github.com/hta-pharma/ramnog + rev: v0.1.1 hooks: - - id: forbid-to-commit - name: Don't commit common R artifacts - entry: Cannot commit .Rhistory, .RData, .Rds or .rds. - language: fail - files: '\.(Rhistory|RData|Rds|rds)$' - # `exclude: ` to allow committing specific files + - id: org-hook