Skip to content

Commit

Permalink
Merge pull request #38 from r-world-devs/maciekbanas/8/set-up-basic-c…
Browse files Browse the repository at this point in the history
…icd-pipeline

Add CI/CD pipeline.
  • Loading branch information
maciekbanas authored Nov 25, 2024
2 parents 685ae28 + 4c3e1af commit e5d6a7c
Show file tree
Hide file tree
Showing 27 changed files with 718 additions and 51 deletions.
8 changes: 8 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^devel
^docs
^pkgdown
^project_metadata.yaml
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
48 changes: 48 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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]
pull_request:
branches: [main]

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: 'release'}

env:
GITHUB_PAT: ${{ secrets.TEST_GITHUB_PAT }}
R_KEEP_PKG_SOURCE: yes
USE_RENV: "FALSE"

steps:
- uses: actions/checkout@v3

- 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

- name: Install R dependencies
run: |
Rscript -e 'install.packages(c("pak", "GitStats", "dplyr", "purrr", "testthat", "xml2", "rcmdcheck"))'
Rscript -e 'pak::pak("tidyverse/elmer")'
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
29 changes: 29 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 🕵 Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/[email protected]

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install R dependencies
run: install.packages("lintr")
shell: Rscript {0}

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -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]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:

name: 🌐 Build site

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.TEST_GITHUB_PAT }}
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

- name: Install R dependencies
run: |
Rscript -e 'install.packages(c("pkgdown", "remotes"))'
Rscript -e 'remotes::install_github("r-world-devs/GitAI")'
- 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/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
62 changes: 62 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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]
pull_request:
branches: [main]

name: 🧪 Test coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.TEST_GITHUB_PAT }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install R dependencies
run: |
Rscript -e 'install.packages(c("pak", "GitStats", "dplyr", "purrr", "covr", "testthat", "xml2"))'
Rscript -e 'pak::pak("tidyverse/elmer")'
- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.Rproj.user
.Renviron
docs
11 changes: 11 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120L),
object_usage_linter = NULL,
object_length_linter = object_length_linter(45L),
object_name_linter = object_name_linter(
styles = c("snake_case", "CamelCase", "symbols"),
regexes = character()
),
cyclocomp_linter = NULL
)
encoding: "UTF-8"
10 changes: 9 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: GitAI
Title: Extracts Knowledge From Git Repositories
Version: 0.0.0.9004
Version: 0.0.0.9005
Authors@R: c(
person("Kamil", "Wais", , "[email protected]", role = c("aut", "cre")),
person("Maciej", "Banas", , "[email protected]", role = "aut")
Expand All @@ -10,6 +10,14 @@ License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Imports:
cli (>= 3.4.0),
elmer,
GitStats,
httr2,
R6,
dplyr,
purrr
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
5 changes: 5 additions & 0 deletions GitAI.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export(set_github_repos)
export(set_gitlab_repos)
export(set_llm)
export(set_prompt)
importFrom(R6,R6Class)
importFrom(httr2,with_verbosity)
3 changes: 3 additions & 0 deletions R/GitAI-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#' @importFrom R6 R6Class
#' @importFrom httr2 with_verbosity
NULL
4 changes: 2 additions & 2 deletions R/GitAI.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ GitAI <- R6::R6Class(
if (is.null(private$.llm))
stop(call. = FALSE, "LLM not set. Use set_llm() first.")

if (missing(value)) return(private$.llm$system_prompt)
private$.llm$system_prompt <- value
if (missing(value)) return(private$.llm$get_system_prompt())
private$.llm$set_system_prompt(value)
},

gitstats = function(value) {
Expand Down
2 changes: 1 addition & 1 deletion R/add_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ is_file_path_pattern <- function(string) {
all(!grepl("^\\*?\\.\\w{2,4}$", string))
}

is_file_type_regex <- function(string){
is_file_type_regex <- function(string) {
all(grepl("^\\*?\\.\\w{2,4}$|^.*\\*\\.\\w{2,4}$", string))
}
1 change: 1 addition & 0 deletions R/global.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
utils::globalVariables("file_content")
3 changes: 2 additions & 1 deletion R/process_repos.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ process_repos <- function(gitai) {

process_content(gitai = gitai, content = content_to_process)

}) |> purrr::set_names(files_content$repo_name)
}) |>
purrr::set_names(files_content$repo_name)

results
}
3 changes: 2 additions & 1 deletion R/set_llm.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param provider A LLM provider.
#' @param model A LLM model.
#' @param seed An integer to make results more reproducible.
#' @param ... Other arguments to pass to `elmer::chat_openai()` function.
#' @return A \code{GitAI} object.
#' @export
set_llm <- function(gitai,
Expand All @@ -27,7 +28,7 @@ set_llm <- function(gitai,

#' Set prompt.
#' @name set_prompt
#' @param gitati A \code{GitAI} object.
#' @param gitai A \code{GitAI} object.
#' @param system_prompt A system prompt.
#' @return A \code{GitAI} object.
#' @export
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ knitr::opts_chunk$set(
# GitAI <img src="man/figures/logo.png" align="right" height="138" style="float:right; height:138px;"/>

<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/r-world-devs/GitAI/graph/badge.svg)](https://app.codecov.io/gh/r-world-devs/GitAI)
<!-- badges: end -->

The goal of GitAI is to derive knowledge from GitHub or GitLab repositories with the use of AI/LLM (Large Language Models). With GitAI you can easily:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# GitAI <img src="man/figures/logo.png" align="right" height="138" style="float:right; height:138px;"/>

<!-- badges: start -->

[![Codecov test
coverage](https://codecov.io/gh/r-world-devs/GitAI/graph/badge.svg)](https://app.codecov.io/gh/r-world-devs/GitAI)
<!-- badges: end -->

The goal of GitAI is to derive knowledge from GitHub or GitLab
Expand Down
5 changes: 5 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: GitAI
url: https://r-world-devs.github.io/GitAI/
template:
bootstrap: 5

2 changes: 2 additions & 0 deletions man/set_llm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/set_prompt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e5d6a7c

Please sign in to comment.