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

タイトル: マージによる機能統合とバグ修正の反映 #7

Merged
merged 102 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
057a9b5
Refactor setup script timeout to 20 minutes for both Ubuntu and macOS
tqer39 Oct 20, 2024
91c604e
Refactor setup script to enable Gatekeeper
tqer39 Oct 21, 2024
5d88227
Refactor setup script to remove Gatekeeper enablement
tqer39 Oct 21, 2024
f920909
Refactor setup script to handle caching and downloading HackGenNerd Font
tqer39 Oct 21, 2024
324dd39
Refactor setup script to handle caching and downloading HackGenNerd F…
tqer39 Oct 21, 2024
5b0409d
Refactor setup script to handle caching and downloading HackGenNerd F…
tqer39 Oct 21, 2024
12cef68
Refactor setup script to fix wget command in Linux environment
tqer39 Oct 21, 2024
ed60313
Refactor setup script to handle caching and downloading HackGenNerd F…
tqer39 Oct 21, 2024
a4c501a
Refactor setup script to remove unnecessary --cask flag when installi…
tqer39 Oct 21, 2024
b99f535
Refactor setup script to handle unsupported OS when installing Google…
tqer39 Oct 21, 2024
528df9c
Refactor setup script to fix cache key for HackGenNerd Font in Linux …
tqer39 Oct 21, 2024
acb7750
Refactor setup script to cache and download HackGenNerd Font in Linux…
tqer39 Oct 21, 2024
bd42f96
Refactor setup script to enable Gatekeeper on macOS
tqer39 Oct 21, 2024
4d6bef0
Refactor setup script to add debug mode
tqer39 Oct 21, 2024
c63bbdf
Refactor setup script to fix file deletion bug in Linux environment
tqer39 Oct 21, 2024
b3c183b
Refactor setup script to download and install HackGen_NF and HackGen …
tqer39 Oct 21, 2024
4357337
Refactor setup script to cache and download HackGenNerd Font in Linux…
tqer39 Oct 21, 2024
8fa98f6
Refactor setup script to cache and download HackGenNerd Font in Linux…
tqer39 Oct 21, 2024
9f34352
Refactor setup script to cache and download HackGenNerd Font in Linux…
tqer39 Oct 21, 2024
abd4e0a
Refactor setup script to cache and download HackGenNerd Font in Linux…
tqer39 Oct 21, 2024
0350068
Refactor setup script to conditionally download and install HackGenNe…
tqer39 Oct 21, 2024
c3b2a85
Merge branch 'main' into feature/setup-rev3
tqer39 Oct 21, 2024
2af9b97
Refactor setup script to use direnv hook based on the user's shell
tqer39 Oct 21, 2024
255f293
Refactor cache path and key for Hyper.js download
tqer39 Oct 21, 2024
ee4762c
Refactor cache path and key for Hyper.js download
tqer39 Oct 22, 2024
9916e04
Refactor environment variable setup and cache path for Hyper.js and H…
tqer39 Oct 22, 2024
d2fc359
Refactor cache path for Hyper.js download
tqer39 Oct 22, 2024
a9915b6
Refactor cache path and key for HackGenNerd Font download
tqer39 Oct 22, 2024
1e8ed8f
Refactor cache path and key for HackGenNerd Font and Hyper.js downloads
tqer39 Oct 22, 2024
1e085d7
Refactor cache path and key for HackGenNerd Font and Hyper.js downloads
tqer39 Oct 22, 2024
5299d53
Refactor cache path and key for HackGenNerd Font and Hyper.js downloads
tqer39 Oct 22, 2024
0393438
Refactor setup script action to add execution permission and run the …
tqer39 Oct 22, 2024
fbde6c5
Add Python version 3.12.1 to .python-version file
tqer39 Oct 23, 2024
9307681
Refactor generate PR description workflow
tqer39 Oct 23, 2024
b08d91b
Refactor generate PR workflow to trigger only on pull requests opened…
tqer39 Oct 23, 2024
d2a83d4
Refactor generate PR workflow to trigger only on pull requests opened…
tqer39 Oct 23, 2024
c1c5d7d
Refactor generate PR workflow to install uv dependency with pip
tqer39 Oct 23, 2024
7cb753f
Refactor .editorconfig to set indent size for Python files
tqer39 Oct 23, 2024
07ccc48
Refactor generate PR workflow to update PR description generation scr…
tqer39 Oct 23, 2024
fb1decd
Refactor generate PR workflow to update PR description generation scr…
tqer39 Oct 23, 2024
b52b213
Refactor generate PR workflow to update PR description generation scr…
tqer39 Oct 23, 2024
cd341eb
Refactor generate PR workflow to enable caching of uv packages
tqer39 Oct 23, 2024
02ce414
Refactor generate PR workflow to remove uv package caching
tqer39 Oct 23, 2024
26a2551
Refactor setup.sh to install necessary packages for pyenv 3.12.1 on L…
tqer39 Oct 24, 2024
7fe1d20
Refactor setup.sh to install necessary packages for pyenv 3.12.1 on L…
tqer39 Oct 24, 2024
32209d8
Refactor setup.sh to conditionally clone anyenv if it doesn't exist
tqer39 Oct 24, 2024
c8aabf2
Refactor setup.sh to clone anyenv if it doesn't exist
tqer39 Oct 24, 2024
f3d8c0c
Refactor setup.sh to conditionally clone anyenv if it doesn't exist a…
tqer39 Oct 24, 2024
b127374
Refactor setup.sh to add .config/git/ignore to dotfiles
tqer39 Oct 24, 2024
8178e20
Refactor setup.sh to install necessary packages for pyenv 3.12.1 on L…
tqer39 Oct 24, 2024
5dfe7c5
Refactor setup.sh to remove unnecessary GUI application installation …
tqer39 Oct 24, 2024
f322a25
Refactor setup.sh to fix CI environment check and variable assignment
tqer39 Oct 24, 2024
a946bcc
Refactor default setup script name in GitHub Actions workflow
tqer39 Oct 24, 2024
5ee774b
Refactor setup.sh to add .config/git/ignore to dotfiles
tqer39 Oct 24, 2024
f3292af
Refactor setup.sh to remove unnecessary GUI application installation …
tqer39 Oct 24, 2024
1de6fb2
Refactor setup.sh to remove unnecessary GUI application installation …
tqer39 Oct 24, 2024
aaf3efe
Refactor setup.sh to fix HackGenNerd Font installation check and add …
tqer39 Oct 24, 2024
d8b452b
Refactor setup.sh to update package manager and install libcrypt-dev
tqer39 Oct 24, 2024
31c7270
Add pyproject.toml with project metadata and dependencies
tqer39 Oct 24, 2024
714604d
Update pyproject.toml with openai dependency
tqer39 Oct 24, 2024
328545b
Update workflow to install dependencies with uv
tqer39 Oct 24, 2024
6f322dc
Update workflow to install dependencies with uv
tqer39 Oct 24, 2024
f271f8a
Update workflow to install dependencies with uv
tqer39 Oct 24, 2024
a358e38
Update workflow to grant write permissions for pull requests
tqer39 Oct 24, 2024
d5b8b8d
Update setup script to remove unnecessary dotfile
tqer39 Oct 24, 2024
4c1200b
Refactor setup script to handle CI environment
tqer39 Oct 24, 2024
9621cb4
Refactor setup script to handle CI environment and remove unnecessary…
tqer39 Oct 24, 2024
099bc03
Refactor setup script to update file paths for dotfiles
tqer39 Oct 24, 2024
be42b23
Refactor setup script to update file paths for dotfiles
tqer39 Oct 24, 2024
aa75063
Refactor setup script to handle CI environment and update file paths …
tqer39 Oct 24, 2024
489525f
Refactor setup script to update file paths for dotfiles
tqer39 Oct 24, 2024
35539bf
Refactor setup script to update file paths for dotfiles and handle CI…
tqer39 Oct 24, 2024
0bc857d
Refactor setup script to update file paths for dotfiles
tqer39 Oct 24, 2024
0476006
Refactor setup script to update file paths for dotfiles and switch to…
tqer39 Oct 24, 2024
381d652
Refactor setup script to update file paths for dotfiles and handle CI…
tqer39 Oct 24, 2024
3bc691d
Refactor setup script to update file paths for dotfiles and remove un…
tqer39 Oct 24, 2024
c2d94a7
Refactor setup script to remove unnecessary branch switch and update …
tqer39 Oct 24, 2024
d3c623d
Refactor setup script to update file paths for dotfiles and handle ap…
tqer39 Oct 24, 2024
346aa30
Refactor setup script to update file paths for dotfiles and handle CI…
tqer39 Oct 24, 2024
98dc836
Refactor setup script to update OpenAI API key retrieval method
tqer39 Oct 24, 2024
904cb8e
Refactor setup script to update file paths for dotfiles and remove un…
tqer39 Oct 24, 2024
1c84b53
Refactor setup script to import the 'os' module for environment varia…
tqer39 Oct 24, 2024
0452a04
Refactor setup script to use OpenAI Python package and update API key…
tqer39 Oct 24, 2024
35f926e
Refactor setup script to use OpenAI Python package and update API key…
tqer39 Oct 24, 2024
7db5ed3
Refactor setup script to fetch latest changes from origin and get dif…
tqer39 Oct 24, 2024
8062762
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 24, 2024
7c22467
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 24, 2024
8ba2b5f
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 24, 2024
83df28c
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 24, 2024
4570dac
Refactor setup script to import subprocess module for command execution
tqer39 Oct 24, 2024
88e804b
Refactor setup script to import subprocess module for command executi…
tqer39 Oct 25, 2024
d6697d3
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 25, 2024
b6dcddd
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 25, 2024
61c6a23
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 25, 2024
65c176a
Refactor setup script to update OpenAI Python package model and API k…
tqer39 Oct 25, 2024
4aa922b
Refactor generate_pr_description.py to update response parsing method
tqer39 Oct 25, 2024
1596a5f
Refactor generate_pr_description.py to limit the number of commit log…
tqer39 Oct 25, 2024
fe49b6a
Refactor generate_pr_description.py to update response parsing method
tqer39 Oct 25, 2024
5a17355
Refactor generate_pr_description.py to limit the number of commit log…
tqer39 Oct 25, 2024
e1f791c
Refactor generate_pr_description.py to increase max_tokens for prompt…
tqer39 Oct 25, 2024
0cc2fff
Refactor generate_pr_description.py to increase max_tokens for prompt…
tqer39 Oct 25, 2024
caf6573
Refactor generate_pr_description.py to fetch remote changes before re…
tqer39 Oct 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
2 changes: 1 addition & 1 deletion .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"

# direnv
eval "$(direnv hook zsh)"
eval "$(direnv hook bash)"

# pbcopy/pbpaste
if command -v xsel &> /dev/null; then
Expand Down
81 changes: 81 additions & 0 deletions .config/git/ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux

# customize
tmp/
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ trim_trailing_whitespace = true

[*.sh]
indent_size = 4

[*.py]
indent_size = 4
3 changes: 2 additions & 1 deletion .github/actions/setup-script/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Runs the setup script and performs checks
inputs:
script:
description: 'The setup script to run'
default: 'setup.sh'
default: 'setup'
required: true

runs:
Expand All @@ -15,6 +15,7 @@ runs:
- name: 実行権限を設定
run: chmod +x ${{ inputs.script }}
shell: bash

- name: セットアップスクリプトを実行
run: ./${{ inputs.script }}
shell: bash
50 changes: 50 additions & 0 deletions .github/workflows/generate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Generate PR Description

on:
pull_request:
branches:
- main

jobs:
generate-pr-description:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5

- name: pip upgrade
run: |
python -m pip install --upgrade pip

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.26"
enable-cache: true
cache-dependency-glob: "requirements**.txt"

- name: Install dependencies with uv
run: |
uv pip install -r requirements.txt --system

- name: Generate PR Title and Description
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
python .github/workflows/scripts/generate_pr_description.py > pr_output.txt
cat pr_output.txt

- name: Update PR Title and Description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PR_TITLE=$(head -n 1 pr_output.txt)
PR_BODY=$(tail -n +2 pr_output.txt)
gh pr edit $PR_NUMBER --title "$PR_TITLE" --body "$PR_BODY"
74 changes: 74 additions & 0 deletions .github/workflows/scripts/generate_pr_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from openai import OpenAI
import os
import subprocess

# OpenAI API キーを設定
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
raise ValueError("API key is not set.")

client = OpenAI(
# This is the default and can be omitted
api_key = os.getenv("OPENAI_API_KEY")
)

# プロンプトの準備
def create_prompt(commit_logs):
return f"""
以下のコミットログとファイルの差分を読んで、わかりやすいプルリクエストのタイトルと詳細な説明を日本語で作成してください。

コミットログとファイルの差分:
{commit_logs}

出力形式:
タイトル: プルリクエストのタイトル
説明:
- 変更点の概要
- 技術的な詳細や注意点
"""

# OpenAI API でのリクエスト
def generate_pr_description(commit_logs):
prompt = create_prompt(commit_logs)

response = client.chat.completions.create(
model="gpt-4o", # GPT-3.5の場合は "gpt-3.5-turbo" に変更
messages=[
{"role": "system", "content": "あなたは優秀なソフトウェアエンジニアです。"},
{"role": "user", "content": prompt},
],
max_tokens=1000,
temperature=0.1,
)

return response.choices[0].message.content.strip()

# Git コミットログとファイルの差分の取得
def get_commit_logs_and_diffs():
# リモートの変更を取得
subprocess.run(['git', 'fetch', 'origin'], check=True)

result = subprocess.run(['git', 'log', '--pretty=format:%H %s', 'origin/main..HEAD', '-n', '70'], capture_output=True, text=True) # コミットログの数を制限
commit_logs = result.stdout.strip().split('\n')

if not commit_logs or commit_logs == ['']:
return ""

logs_and_diffs = []
for commit in commit_logs:
commit_hash = commit.split()[0]
if commit_hash:
diff_result = subprocess.run(['git', 'diff', commit_hash + '^!', '--'], capture_output=True, text=True)
logs_and_diffs.append(f"Commit: {commit}\nDiff:\n{diff_result.stdout}")

return "\n\n".join(logs_and_diffs)

# メインロジック
if __name__ == "__main__":
commit_logs_and_diffs = get_commit_logs_and_diffs()

if commit_logs_and_diffs:
pr_description = generate_pr_description(commit_logs_and_diffs)
print(pr_description)
else:
print("No new commits detected.")
92 changes: 84 additions & 8 deletions .github/workflows/test-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,128 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
# pull_request:
# branches:
# - main
workflow_dispatch:

env:
HACKGEN_VERSION: "2.9.0"
DL_PATH: "$HOME/Downloads"
HACKGEN_VERSION: "2.9.0"
HYPER_VERSION: "3.4.1"

jobs:
test-ubuntu:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up environment variables
run: |
echo "DL_PATH=$HOME/Downloads" >> $GITHUB_ENV
echo "HACKGEN_VERSION=2.9.0" >> $GITHUB_ENV
echo "HYPER_VERSION=3.4.1" >> $GITHUB_ENV

- name: Cache HackGenNerd Font
id: cache-hackgen-nf
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}
key: ${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}-
restore-keys: |
${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}
${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}-

- name: Download HackGenNerd Font
if: steps.cache-hackgen-nf.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip"

- name: Cache HackGen
id: cache-hackgen
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}
key: ${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}-
restore-keys: |
${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}
${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}-

- name: Download HackGen
if: steps.cache-hackgen.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip"

- name: Cache Hyper.js
id: cache-hyper
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/deb
key: ${{ runner.os }}-hyper-js-${{ env.HYPER_VERSION }}-
restore-keys: |
${{ runner.os }}-hyper-js-${{ env.HYPER_VERSION }}-

- name: Download Hyper.js
if: steps.cache-hyper.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://releases.hyper.is/download/deb"

- uses: ./.github/actions/setup-script

test-macos:
timeout-minutes: 20
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Set up environment variables
run: |
echo "DL_PATH=$HOME/Downloads" >> $GITHUB_ENV
echo "HACKGEN_VERSION=2.9.0" >> $GITHUB_ENV
echo "HYPER_VERSION=3.4.1" >> $GITHUB_ENV

- name: Cache HackGenNerd Font
id: cache-hackgen-nf
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}-
restore-keys: |
${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}-

- name: Download HackGenNerd Font
if: steps.cache-hackgen-nf.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip"

- name: Cache HackGen
id: cache-hackgen
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}-
restore-keys: |
${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}-

- name: Download HackGen
if: steps.cache-hackgen.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip"

- name: Cache Hyper.js
id: cache-hyper
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/deb
key: ${{ runner.os }}-hyper-js-${{ env.HYPER_VERSION }}-
restore-keys: |
${{ runner.os }}-hyper-js-${{ env.HYPER_VERSION }}-

- name: Download Hyper.js
if: steps.cache-hyper.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://releases.hyper.is/download/deb"

- name: Enable Gatekeeper
run: sudo spctl --master-enable

- uses: ./.github/actions/setup-script
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.1
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "local-workspace-provisioning"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"openai==1.52.1",
]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openai==1.52.1
Loading