GitHub & Pull Request
コードのSNS。レビュー文化とCI/CDの基盤。
用語集
Pull Request
マージ提案。レビュー依頼。
レビュー
コードの確認とフィードバック。
CI
継続的インテグレーション。自動テスト。
Actions
GitHub上で動くワークフロー自動化。
PRワークフロー
プルリクエストを使った開発フローの基本。
# 1. Create feature branch and make changesgit switch -c feature/user-profile# ... edit files ...git add .git commit -m "feat: Add user profile page"
# 2. Push to GitHubgit push origin feature/user-profile
# 3. Open Pull Request on GitHub# (via browser or gh CLI)
# 4. After review approval, merge on GitHub# 5. Pull the merged changes locallygit switch maingit pull origin main実行結果
remote: Create a pull request for 'feature/user-profile' on GitHub by visiting: remote: https://github.com/user/repo/pull/new/feature/user-profile
良いPRの書き方
レビュアーが理解しやすいPRを書くことで、マージまでの時間が短縮されます。
Bad
## Bug fix
Fixed stuffGood
## SummaryAdd user profile page with avatar upload
## Changes- Add ProfileForm component- Add avatar upload with size validation- Add unit tests for image resizing
## How to Test1. Run `npm run dev`2. Navigate to /settings/profile3. Upload an image (max 5MB)
## Screenshots(Attach before/after screenshots) Tip: .github/PULL_REQUEST_TEMPLATE.md を作成すると、PRテンプレートが自動適用される。
GitHub Actions (CI/CD)
pushやPR作成時に自動でテストやビルドを実行する。
# .github/workflows/ci.ymlname: CI
on: push: branches: [main] pull_request: branches: [main]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm'
- name: Install dependencies run: npm ci
- name: Run tests run: npm test
- name: Build run: npm run buildGitHub上での表示
✓ CI / test (pull_request) ✓ Setup Node.js (2s) ✓ Install dependencies (15s) ✓ Run tests (8s) ✓ Build (25s)
合格ライン
PRを作成してマージできる
良いPRテンプレートを書ける
GitHub Actionsのワークフローを読める
レビューコメントを適切に書ける
参考リンク
演習課題
課題1: 初めてのPR
自分のリポジトリでブランチを作成し、プルリクエストを開いてみてください。
課題2: PR Description
Summary, Changes, How to Test を含む詳細な PR 説明文を書いてみてください。