Skip to content

Commit

Permalink
feat: Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 6, 2024
1 parent 972b7cc commit 824933c
Show file tree
Hide file tree
Showing 128 changed files with 6,144 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
groups:
all:
patterns:
- "*"
ignore:
- dependency-name: Microsoft.CodeAnalysis.CSharp
62 changes: 62 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Opens a new PR if there are format updates
on:
schedule:
- cron: '00 5 * * 1'

permissions:
contents: write
pull-requests: write
actions: write

jobs:
together:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Git user
run: |
git config --local user.email "auto-format-bot@langchain.com"
git config --local user.name "github-actions[bot]"
- name: Generate branch name
id: branch
run: echo "branch_name=bot/auto-format_$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT

- name: Create branch
run: |
git checkout -b ${{ steps.branch.outputs.branch_name }} origin/main
git rebase main
- name: Format code
run: |
dotnet format LangChain.sln
dotnet format LangChain.sln analyzers --diagnostics=RS0016
- name: Check for changes
id: changes
run: |
CHANGED=$(git diff --name-only)
if [ -z "$CHANGED" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git add .
git commit -m "style: Run dotnet format"
git push --force-with-lease -u origin ${{ steps.branch.outputs.branch_name }}
- name: Wait for 15 seconds
if: steps.changes.outputs.has_changes == 'true'
run: sleep 15

- name: Create pull request
if: steps.changes.outputs.has_changes == 'true'
run: gh pr create -B main -H ${{ steps.branch.outputs.branch_name }} --title 'style:Run dotnet format' --body 'Created by Github Actions'
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/auto-labeling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Auto-labeling issue
on:
issues:
types:
- opened
- reopened

jobs:
label_issue:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get labels
id: labels
env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
run: |
LABELS=$(gh label list --jq '.[].name' --json name | tr '\n' ',')
echo "available_labels=$LABELS" >> $GITHUB_OUTPUT
- name: Install LangChain CLI
run: |
dotnet tool install --global langchain.cli --prerelease
langchain auth openai ${{ secrets.OPENAI_API_KEY }} --model gpt-4-turbo
- name: Prepare prompt
run: |
echo "Return arguments for `gh issue edit $ISSUE_URL $ARGUMENTS_WILL_BE_HERE$` for issue with these data:" > prompt.txt
echo "Title: ${{ github.event.issue.title }}" >> prompt.txt
echo "Body: ${{ github.event.issue.body }}" >> prompt.txt
echo "Available labels: ${{ steps.labels.outputs.available_labels }}" >> prompt.txt
echo " " >> prompt.txt
echo "IMPORTANT: Return ONLY replacement for $ARGUMENTS_WILL_BE_HERE$. It should contains one or more --add-label arguments" >> prompt.txt
echo "Example output: --add-label \"vector databases\" --add-label \"enhancement\"" >> prompt.txt
cat prompt.txt
- name: Analyse issue
id: analyse
run: |
ARGUMENTS=$(langchain generate --input-file prompt.txt)
echo $ARGUMENTS
echo "arguments=$ARGUMENTS" >> $GITHUB_OUTPUT
- env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
run: |
gh issue edit ${{ github.event.issue.html_url }} ${{ steps.analyse.outputs.arguments }}
43 changes: 43 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto-approve and auto-merge bot pull requests
on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
runs-on: ubuntu-latest
if: ${{ (github.actor == 'dependabot[bot]' || github.actor == 'allcontributors[bot]' || github.actor == 'HavenDV') && github.repository_owner == 'tryAGI' }}
steps:
- name: Dependabot metadata
if: ${{ github.actor == 'dependabot[bot]' }}
id: metadata
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Show sender
run: echo ${{ github.event.pull_request.sender }}

- name: Show triggering_actor
run: echo ${{ github.triggering_actor }}

- name: Approve a PR
# Only if version bump is not a major version change
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' || github.actor == 'allcontributors[bot]' || github.actor == 'HavenDV' }}
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable auto-merge
# Only if version bump is not a major version change
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' || github.actor == 'allcontributors[bot]' || github.actor == 'HavenDV' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build, test and publish
on:
push:
branches:
- main
tags:
- v**

jobs:
build-test-publish:
name: Build, test and publish
uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main
with:
generate-build-number: false
conventional-commits-publish-conditions: false
additional-test-arguments: '--logger GitHubActions'
secrets:
nuget-key: ${{ secrets.NUGET_KEY }}

todo-to-issue:
name: Run TODO to Issue
if: github.event.ref == 'refs/heads/main'
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v4"
54 changes: 54 additions & 0 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: MKDocs Deploy
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'examples/**'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Install dependencies
run: pip install mkdocs-material

- name: Generate docs
run: dotnet run --project src/Helpers/GenerateDocs/GenerateDocs.csproj .

- name: Build with MkDocs
run: mkdocs build -d ./_site

- name: Upload artifact
uses: actions/upload-pages-artifact@v3

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
14 changes: 14 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build and test
on:
pull_request:
branches:
- main

jobs:
build-test:
name: Build and test
uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main
with:
generate-build-number: false
conventional-commits-publish-conditions: false
additional-test-arguments: '--logger GitHubActions'
Loading

0 comments on commit 824933c

Please sign in to comment.