Skip to content
Merged

ci/cd #144

Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
addReviewers: true
addAssignees: false
reviewers:
- team-backend
- team-frontend
skipDraft: true
48 changes: 48 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ----------------------------------------------------
# Area Labels: Based on what part of the app is touched
# ----------------------------------------------------
'area: flutter':
- changed-files:
- any-glob-to-any-file:
- 'lib/**'
- '**/*.dart'

'area: web':
- changed-files:
- any-glob-to-any-file:
- 'web/**'
- 'frontend/src/**'
- 'package.json' # Catches root web dependencies

'area: backend':
- changed-files:
- any-glob-to-any-file:
- 'backend/**'
- 'server/src/**'
- 'go.mod' # Example for Go
- 'requirements.txt' # Example for Python

# ----------------------------------------------------
# Type Labels: Based on the type of change
# ----------------------------------------------------
'type: ci/cd':
- changed-files:
- any-glob-to-any-file:
- '.github/workflows/**'
- '.github/auto_assign.yml'
- '.github/labeler.yml'
- 'mergify.yml'

'type: docs':
- changed-files:
- any-glob-to-any-file:
- 'docs/**'
- 'README.md'
- 'CONTRIBUTING.md'

'type: config':
- changed-files:
- any-glob-to-any-file:
- 'scripts/**'
- '.firebaserc'
- 'firebase.json'
27 changes: 27 additions & 0 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: wishper-bot
on:
issue_comment:
types: [created]

permissions:
issues: write
pull-requests: write
contents: write

jobs:
bot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: |
cd scripts/bot
npm ci
- run: |
cd scripts/bot
node index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TZ: Asia/Kolkata
152 changes: 152 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: CI
on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]
workflow_dispatch: {}

jobs:
flutter:
name: Flutter (frontend2)
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend2
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- run: |
flutter pub get
flutter analyze --no-fatal-infos
flutter test --coverage

web-hab:
name: Web (hab-frontend)
runs-on: ubuntu-latest
defaults:
run:
working-directory: hab-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'hab-frontend/package-lock.json'
- run: |
npm ci
npm run lint --if-present
npm test --if-present

web-hostel:
name: Web (hostel-frontend)
runs-on: ubuntu-latest
defaults:
run:
working-directory: hostel-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'hostel-frontend/package-lock.json'
- run: |
npm ci
npm run lint --if-present
npm test --if-present

web-login:
name: Web (login-frontend)
runs-on: ubuntu-latest
defaults:
run:
working-directory: login-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'login-frontend/package-lock.json'
- run: |
npm ci
npm run lint --if-present
npm test --if-present

web-smc:
name: Web (smc-frontend)
runs-on: ubuntu-latest
defaults:
run:
working-directory: smc-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'smc-frontend/package-lock.json'
- run: |
npm ci
npm run lint --if-present
npm test --if-present

backend:
name: Backend (server)
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'server/package-lock.json'
- name: Install, Build, Lint, and Test
run: |
npm ci
npm run lint --if-present
npm run build --if-present
npm test --if-present

deploy-staging:
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
needs: [flutter, web-hab, web-hostel, web-login, web-smc, backend]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Run staging deploy script
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
run: bash ./scripts/deploy_staging.sh

deploy-prod:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [flutter, web-hab, web-hostel, web-login, web-smc, backend]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Run production deploy script
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
run: bash ./scripts/deploy_prod.sh
110 changes: 110 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: PR Open Automation
on:
pull_request:
types: [opened]

permissions:
pull-requests: write
issues: write
contents: read

jobs:
automate:
runs-on: ubuntu-latest
steps:
- name: Apply labels from .github/labeler.yml
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Assign Reviewer (r? or Random)
uses: actions/github-script@v7
with:
script: |
// --- CONFIGURATION ---
// ⚠️ ADD YOUR LIST OF REVIEWERS HERE
const all_reviewers = ['nilotpal-n7', 'quintessa-n7'];
// --- END CONFIGURATION ---

const pr_body = context.payload.pull_request.body || "";
const pr_number = context.payload.pull_request.number;
const pr_author = context.payload.pull_request.user.login;
let reviewer_to_assign;

const regex = /r\?\s*@([a-zA-Z0-9-]+)/;
const match = pr_body.match(regex);

if (match) {
// 1. Found `r? @user` in the PR message
reviewer_to_assign = match[1];
console.log(`Found explicit reviewer: ${reviewer_to_assign}`);
} else {
// 2. Not found. Pick a random reviewer.
// Filter out the PR author so they can't be assigned their own PR
const potential_reviewers = all_reviewers.filter(user => user !== pr_author);
const random_index = Math.floor(Math.random() * potential_reviewers.length);
reviewer_to_assign = potential_reviewers[random_index];
console.log(`Assigning random reviewer: ${reviewer_to_assign}`);
}

if (reviewer_to_assign) {
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_number,
reviewers: [reviewer_to_assign]
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
body: `✅ Reviewer assignment: @${reviewer_to_assign} has been assigned for review.`
});
} else {
console.log('Could not determine a reviewer to assign.');
}

- name: CC Owners based on Labels
uses: actions/github-script@v7
with:
script: |
// --- CONFIGURATION ---
// ⚠️ MAP YOUR LABELS TO YOUR TEAMS/OWNERS HERE
const label_to_owner = {
'area: flutter': '@team-flutter',
'area: backend': '@team-backend',
'area: web': '@team-frontend',
'type: ci/cd': '@team-devops' // Example
};
// --- END CONFIGURATION ---

const pr_labels = context.payload.pull_request.labels.map(label => label.name);
const owners_to_cc = new Set();

for (const label of pr_labels) {
if (label_to_owner[label]) {
owners_to_cc.add(label_to_owner[label]);
}
}

if (owners_to_cc.size > 0) {
const comment_body = `🔔 FYI: ${[...owners_to_cc].join(', ')} (CC'ing you based on PR labels for changes in your area.)`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: comment_body
});
} else {
console.log('No owners to CC for these labels.');
}

- name: Comment PR Checklist
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
✅ **Automated checks triggered**
- [ ] CI jobs passing
- [ ] Reviewer approval
- [ ] Ready label applied
15 changes: 15 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Stale
on:
schedule:
- cron: '0 0 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30
days-before-close: 7
stale-issue-message: '⏳ This PR/issue has been inactive for 30 days.'
2 changes: 2 additions & 0 deletions .husky/_/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
. "$(dirname "$0")/h"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
Loading
Loading