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

Add CI/CD pipeline. #38

Merged
merged 47 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cba8ff2
Update package to comply with local cmd-checks.
maciekbanas Nov 19, 2024
8440eef
Add test-coverage job with use_this.
maciekbanas Nov 19, 2024
da12a35
Knit Readme with badge.
maciekbanas Nov 19, 2024
60b7267
Try install elmer in job.
maciekbanas Nov 19, 2024
0acd47e
Try different approach with elmer.
maciekbanas Nov 19, 2024
ac3777d
Add elmer.
maciekbanas Nov 19, 2024
b5eb696
Try new approach with elmer.
maciekbanas Nov 19, 2024
3d21ba0
Update renv.
maciekbanas Nov 19, 2024
555c1db
Update image with elmer installed with pak.
maciekbanas Nov 19, 2024
f0cb71a
Test solution.
maciekbanas Nov 19, 2024
430df94
Add covr.
maciekbanas Nov 19, 2024
a95eb0a
Install dependencies.
maciekbanas Nov 19, 2024
c118fba
Fix.
maciekbanas Nov 19, 2024
33beb19
Apply lint.
maciekbanas Nov 20, 2024
d48be32
Update renv.
maciekbanas Nov 20, 2024
aa50e87
Adjust to changes in elmer: use `set_system_prompt()` and `get_system…
maciekbanas Nov 20, 2024
2ce5825
Merge pull request #40 from r-world-devs/maciekbanas/39/respond-to-ch…
maciekbanas Nov 20, 2024
c5c3536
Update secrets with GITHUB_PAT with wider scope.
maciekbanas Nov 20, 2024
2dda25a
Fix test. Paragraph with shorter lines resulted in different output t…
maciekbanas Nov 20, 2024
91ddea5
Add lint job.
maciekbanas Nov 20, 2024
9d69440
Fixes.
maciekbanas Nov 20, 2024
d018426
Move out install dependencies and call it in all workflows.
maciekbanas Nov 20, 2024
f7ed504
Fix.
maciekbanas Nov 20, 2024
9eca78d
Fix path.
maciekbanas Nov 20, 2024
7105cfc
Fix.
maciekbanas Nov 20, 2024
581c85c
Fix.
maciekbanas Nov 20, 2024
bc656aa
Fix path.
maciekbanas Nov 20, 2024
e5bc813
Fix path.
maciekbanas Nov 20, 2024
f6a9d8c
Try fix.
maciekbanas Nov 20, 2024
6c566bd
Use path.
maciekbanas Nov 20, 2024
0f7bd0b
Try new path.
maciekbanas Nov 20, 2024
c0b21c5
One more time.
maciekbanas Nov 20, 2024
f369237
Try fix.
maciekbanas Nov 20, 2024
92813e4
Try fix.
maciekbanas Nov 20, 2024
7cc752e
Try fix.
maciekbanas Nov 20, 2024
2fa1b41
Try fix.
maciekbanas Nov 20, 2024
91c961e
Try fix.
maciekbanas Nov 20, 2024
e52b4a0
Get back to previous solution.
maciekbanas Nov 20, 2024
227b2f0
Fix.
maciekbanas Nov 20, 2024
97261fc
Try fix.
maciekbanas Nov 20, 2024
b284973
Add pkgdown job.
maciekbanas Nov 20, 2024
b4f9abf
Try common approach.
maciekbanas Nov 20, 2024
12145d2
Try fix job.
maciekbanas Nov 20, 2024
b0bd72c
Fix.
maciekbanas Nov 20, 2024
0f8d6d3
Update gitignore.
maciekbanas Nov 20, 2024
44bad11
Fix dependencies.
maciekbanas Nov 20, 2024
4c3e1af
After code review: lint tests.
maciekbanas Nov 25, 2024
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
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
krystian8207 marked this conversation as resolved.
Show resolved Hide resolved
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 }}
krystian8207 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v4.1.4

- 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")'
krystian8207 marked this conversation as resolved.
Show resolved Hide resolved

- 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
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", , "kamil.wais@gmail.com", role = c("aut", "cre")),
person("Maciej", "Banas", , "banasmaciek@gmail.com", 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
Loading