From 7f30afb6f4794623765411547e7abdd9f85f002d Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Fri, 27 Sep 2024 06:36:33 +0000 Subject: [PATCH 1/2] Adds gh deployment job. --- .github/workflows/pkgdown.yaml | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/pkgdown.yaml diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 00000000..4bbce750 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,50 @@ +# 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.yaml + +permissions: read-all + +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 From 52e926f16937cb373087b70cb42fd7ded35fb00a Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Fri, 27 Sep 2024 09:48:58 +0000 Subject: [PATCH 2/2] Mock some tests to get them faster. --- tests/testthat/test-get_commits-GitHub.R | 5 ++++ .../testthat/test-get_files_content-GitHub.R | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/testthat/test-get_commits-GitHub.R b/tests/testthat/test-get_commits-GitHub.R index e44bf147..5c239cb5 100644 --- a/tests/testthat/test-get_commits-GitHub.R +++ b/tests/testthat/test-get_commits-GitHub.R @@ -63,6 +63,11 @@ test_that("`get_commits_from_one_repo()` prepares formatted list", { }) test_that("`get_commits_from_repos()` pulls commits from repos", { + mockery::stub( + test_graphql_github$get_commits_from_repos, + "private$get_commits_from_one_repo", + test_mocker$use("commits_from_repo") + ) commits_from_repos <- test_graphql_github$get_commits_from_repos( org = "r-world-devs", repo = "GitStats", diff --git a/tests/testthat/test-get_files_content-GitHub.R b/tests/testthat/test-get_files_content-GitHub.R index d186365a..b670b031 100644 --- a/tests/testthat/test-get_files_content-GitHub.R +++ b/tests/testthat/test-get_files_content-GitHub.R @@ -24,7 +24,24 @@ test_that("get_repos_data pulls data on repos and branches", { ) }) +test_that("GitHub GraphQL Engine pulls file response", { + github_file_response <- test_graphql_github_priv$get_file_response( + org = "r-world-devs", + repo = "GitStats", + def_branch = "master", + file_path = "LICENSE", + files_query = test_mocker$use("gh_file_blobs_from_repo_query") + ) + expect_github_files_response(github_file_response) + test_mocker$cache(github_file_response) +}) + test_that("GitHub GraphQL Engine pulls files from organization", { + mockery::stub( + test_graphql_github$get_files_from_org, + "private$get_file_response", + test_mocker$use("github_file_response") + ) github_files_response <- test_graphql_github$get_files_from_org( org = "r-world-devs", repos = NULL, @@ -53,6 +70,11 @@ test_that("GitHub GraphQL Engine pulls .png files from organization", { }) test_that("GitHub GraphQL Engine pulls files from defined repositories", { + mockery::stub( + test_graphql_github$get_files_from_org, + "private$get_file_response", + test_mocker$use("github_file_response") + ) github_files_response <- test_graphql_github$get_files_from_org( org = "openpharma", repos = c("DataFakeR", "visR"), @@ -67,6 +89,11 @@ test_that("GitHub GraphQL Engine pulls files from defined repositories", { }) test_that("GitHub GraphQL Engine pulls two files from a group", { + mockery::stub( + test_graphql_github$get_files_from_org, + "private$get_file_response", + test_mocker$use("github_file_response") + ) github_files_response <- test_graphql_github$get_files_from_org( org = "r-world-devs", repos = NULL,