Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create github.R #301

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you revert this or sync to master

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name: R-CMD-check

jobs:
R-CMD-check:
runs-on: macOS-latest
runs-on: macOS-13
strategy:
matrix:
r-version: ['4.2']
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Install UCtags and Update tools.yml
if: always()
run: |
brew tap universal-ctags/universal-ctags
brew tap homebrew/core
brew install --HEAD universal-ctags
utags_head=$(ls /usr/local/Cellar/universal-ctags | tail -n 1)
sed -i -e "s|utags: \/usr\/local\/Cellar\/universal-ctags\/HEAD-62f0144\/bin\/ctags|utags: \/usr\/local\/Cellar\/universal-ctags\/${utags_head}\/bin\/ctags|g" tools.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same on revert to master

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: test-coverage

jobs:
test-coverage:
runs-on: macOS-latest
runs-on: macOS-13
strategy:
matrix:
r-version: ['4.2']
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Install UCtags and Update tools.yml
if: always()
run: |
brew tap universal-ctags/universal-ctags
brew tap homebrew/core
brew install --HEAD universal-ctags
utags_head=$(ls /usr/local/Cellar/universal-ctags | tail -n 1)
sed -i -e "s|utags: \/usr\/local\/Cellar\/universal-ctags\/HEAD-62f0144\/bin\/ctags|utags: \/usr\/local\/Cellar\/universal-ctags\/${utags_head}\/bin\/ctags|g" tools.yml
Expand Down
100 changes: 100 additions & 0 deletions exec/github.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/local/bin/Rscript

# Kaiaulu - https://github.com/sailuh/kaiaulu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

require(yaml,quietly=TRUE)
require(cli,quietly=TRUE)
require(docopt,quietly=TRUE)
require(kaiaulu,quietly=TRUE)
require(data.table,quietly=TRUE)
require(jsonlite,quietly=TRUE)
require(knitr,quietly=TRUE)
require(magrittr,quietly=TRUE)
require(gt,quietly=TRUE)


# Rscript github.R refresh issues ../../kaiaulu/conf/kaiaulu.yml ../../rawdata/github/kaiaulu/issue_search/
# Rscript github.R refresh comments ../../kaiaulu/conf/kaiaulu.yml ../../rawdata/github/kaiaulu/issue_search/

doc <- "
USAGE:
github refresh help
github refresh issues <project_conf.yml> <save_file_name_path>
github refresh comments <project_conf.yml> <save_file_name_path>
github download Github help
github (-h | --help)
github --version

DESCRIPTION:
Provides functions to refresh Github issue data. Please see
Kaiaulu's README.md for instructions on how to create <project_conf.yml>.


OPTIONS:
-h --help Show this screen.
--version Show version.
"



arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600')
if(arguments[["refresh"]] & arguments[["help"]]){
cli_alert_info("Downloads new data from Github Rest API")
}else if(arguments[["refresh"]] & arguments [["issues"]]){

conf_path <- arguments[["<project_conf.yml>"]]
save_path <- arguments[["<save_file_name_path>"]]

conf <- yaml::read_yaml(conf_path)

save_path <- path.expand(conf[["issue_tracker"]][["github"]][["replies"]])
save_path_issue_refresh <- paste0(save_path,"/issue_search/")
save_path_issue <- paste0(save_path,"/issue/")
save_path_issue_or_pr_comments <- paste0(save_path,"/issue_or_pr_comment/")
# Path you wish to save all raw data. A folder with the repo name and sub-folders will be created.
owner <- conf[["issue_tracker"]][["github"]][["owner"]] # Has to match github organization (e.g. github.com/sailuh)
repo <- conf[["issue_tracker"]][["github"]][["repo"]] # Has to match github repository (e.g. github.com/sailuh/perceive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded get

# your file github_token (a text file) contains the GitHub token API
token <- scan("~/.ssh/github_token",what="character",quiet=TRUE)

gh_response <- github_api_project_issue_refresh(owner,
repo,
token,
save_path_issue_refresh,
verbose=TRUE)
github_api_iterate_pages(token,gh_response,
save_path_issue_refresh,
prefix="issue",
verbose=TRUE)

cli_alert_success(paste0("Downloaded new Github issues saved at: ",save_path_issue_refresh))
}else if(arguments[["refresh"]] & arguments [["comments"]]){

conf <- yaml::read_yaml("../conf/kaiaulu.yml")
save_path <- path.expand(conf[["issue_tracker"]][["github"]][["replies"]])
save_path_issue_or_pr_comments <- paste0(save_path,"/issue_or_pr_comment/")
# Path you wish to save all raw data. A folder with the repo name and sub-folders will be created.
owner <- conf[["issue_tracker"]][["github"]][["owner"]] # Has to match github organization (e.g. github.com/sailuh)
repo <- conf[["issue_tracker"]][["github"]][["repo"]] # Has to match github repository (e.g. github.com/sailuh/perceive)
# your file github_token (a text file) contains the GitHub token API
token <- scan("~/.ssh/github_token",what="character",quiet=TRUE)

gh_response_issue_or_pr_comment <- github_api_project_issue_or_pr_comment_refresh(owner,
repo,
token, save_path_issue_or_pr_comments, verbose=TRUE)

# create directory and iterate over data
#dir.create(save_path_issue_or_pr_comments)
github_api_iterate_pages(token,gh_response_issue_or_pr_comment,
save_path_issue_or_pr_comments,
prefix="issue_or_pr_comment",
verbose=TRUE)
}




Loading