-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge branch qa into feat/providers
-e Signed-off-by: Brian Chebon <[email protected]>
- Loading branch information
Showing
15 changed files
with
359 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This workflow valides that branch and commit names are standardized for better workflow. | ||
|
||
name: Coverage Workflow | ||
|
||
on: | ||
workflow_call: # Makes the workflow reusable | ||
inputs: | ||
branch_name: | ||
required: true | ||
type: string | ||
event_name: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
upload-coverage: | ||
runs-on: ubuntu-latest | ||
needs: test-and-upload | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} | ||
slug: open-feature/dart-server-sdk | ||
files: ./coverage/lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Notifications | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited, deleted] | ||
push: | ||
branches: [main] | ||
pull_request: | ||
types: [opened, edited, closed, reopened, synchronize] | ||
deployment_status: | ||
release: | ||
|
||
jobs: | ||
notify: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
steps: | ||
- id: 'notify_google_chat' | ||
uses: 'google-github-actions/[email protected]' | ||
with: | ||
webhook_url: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
### **README for Local Git Hooks** | ||
|
||
#### **Introduction** | ||
This repository provides optional local Git hooks to help developers maintain code quality and adhere to commit conventions before pushing changes to the repository. These hooks automate checks during various stages of the Git workflow, ensuring that issues are caught early in the development process. | ||
|
||
--- | ||
|
||
### **What Are Git Hooks?** | ||
Git hooks are scripts that Git runs automatically at specific points in your workflow. Local Git hooks can be set up in your development environment to run checks before commits, pushes, or other Git actions. These hooks are not automatically shared across the team, so developers must configure them manually. | ||
|
||
This repository includes three hooks for development: | ||
1. **Pre-Commit Hook (`pre-commit`)**: Validates code before committing. | ||
2. **Commit Message Hook (`commit-msg`)**: Ensures commit messages adhere to conventions. | ||
3. **Pre-Push Hook (`pre-push`)**: Validates the branch name before allowing a push. | ||
|
||
--- | ||
|
||
### **Included Hooks** | ||
#### **1. Pre-Commit Hook** | ||
- **Location**: `./local_dev_tools/validate_commit.dart` | ||
- **Purpose**: Validates the code (e.g., linting or formatting) before allowing the commit. | ||
- **When It Runs**: Automatically triggered before `git commit`. | ||
- **Usage**: | ||
- Ensures all code complies with the repository's coding standards. | ||
- Prevents committing code with syntax errors or formatting issues. | ||
|
||
#### **2. Commit Message Hook** | ||
- **Location**: `./local_dev_tools/validate_commit_msg.dart` | ||
- **Purpose**: Ensures commit messages follow the repository's commit message conventions (e.g., Conventional Commits). | ||
- **When It Runs**: Automatically triggered after you enter a commit message. | ||
- **Usage**: | ||
- Validates the format of commit messages, ensuring clear and consistent commit history. | ||
- Prevents commits with messages that fail validation. | ||
|
||
#### **3. Pre-Push Hook** | ||
- **Location**: `./local_dev_tools/validate_branch.dart` | ||
- **Purpose**: Checks branch names or other repository-specific rules before pushing changes. | ||
- **When It Runs**: Automatically triggered before `git push`. | ||
- **Usage**: | ||
- Ensures that the branch name follows naming conventions. | ||
- Can block pushes from unintended branches (e.g., `main` or `master`). | ||
|
||
--- | ||
|
||
### **Setup Instructions** | ||
To enable these hooks in your local development environment: | ||
|
||
#### **1. Install Hooks** | ||
Run the following command to configure the hooks: | ||
```bash | ||
git config core.hooksPath ./local_dev_tools/ | ||
``` | ||
|
||
This command tells Git to look for hooks in the `./local_dev_tools` directory instead of the default `.git/hooks` directory. | ||
|
||
--- | ||
|
||
### **How Developers Can Use These Hooks** | ||
1. **Pre-Commit Checks**: | ||
- When you run `git commit`, the `pre-commit` hook will validate your code. | ||
- If any issues are detected (e.g., linting errors), the commit will be blocked, and you’ll be prompted to fix them. | ||
|
||
2. **Commit Message Validation**: | ||
- After you write a commit message, the `commit-msg` hook will check the message format. | ||
- If the message doesn’t adhere to the required format, the commit will be rejected with instructions for fixing it. | ||
|
||
3. **Pre-Push Validation**: | ||
- When you run `git push`, the `pre-push` hook will check the branch name or other repository-specific rules. | ||
- If the branch name is invalid or rules are violated, the push will be blocked. | ||
|
||
--- | ||
|
||
### **FAQs** | ||
|
||
#### **Q: Are these hooks mandatory?** | ||
No, these hooks are optional. However, they are recommended to maintain consistency and quality. | ||
|
||
#### **Q: How do I disable the hooks temporarily?** | ||
To bypass hooks during a specific operation, use the `--no-verify` flag: | ||
```bash | ||
git commit --no-verify | ||
git push --no-verify | ||
``` | ||
|
||
#### **Q: Can I customize the hooks?** | ||
Yes, you can modify the hook scripts (`validate_commit.dart`, `validate_commit_msg.dart`, and `validate_branch.dart`) to suit your project’s needs. | ||
|
||
--- | ||
|
||
# Automatically add Signed-off-by to commit message | ||
#!/bin/bash | ||
|
||
if ! grep -q "Signed-off-by:" "$1"; then | ||
echo "Signed-off-by: $(git config user.name) <$(git config user.email)>" >> "$1" | ||
fi | ||
|
||
chmod +x .git/hooks/prepare-commit-msg | ||
|
||
### **Additional Notes** | ||
- These hooks run locally on your machine and do not affect other developers. | ||
- Hooks ensure that most issues are caught during development, saving time and effort during code reviews and CI/CD processes. | ||
|
||
For further assistance, feel free to contact the repository maintainers. Happy coding! 🎉 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:io'; | ||
|
||
void main(List<String> args) { | ||
print('Validating branch name...'); | ||
|
||
// Retrieve the branch name | ||
final result = Process.runSync('git', ['rev-parse', '--abbrev-ref', 'HEAD']); | ||
final branchName = result.stdout.toString().trim(); | ||
|
||
if (branchName.isEmpty) { | ||
print('❌ Could not determine branch name.'); | ||
exit(1); | ||
} | ||
|
||
print('Branch name: $branchName'); | ||
|
||
final validBranches = RegExp(r'^(qa|beta|main)$'); | ||
final validFeatureBranch = | ||
RegExp(r'^(feat|fix|hotfix|chore|test|refactor|release)/[a-z0-9_-]+$'); | ||
|
||
if (validBranches.hasMatch(branchName) || | ||
validFeatureBranch.hasMatch(branchName)) { | ||
print('✅ Branch name is valid.'); | ||
} else { | ||
print( | ||
'❌ Branch name does not follow the required convention: <type>/<branch-name>'); | ||
print( | ||
'Valid types: feat, fix, hotfix, chore, test, refactor, release, qa, beta, main'); | ||
exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'dart:io'; | ||
|
||
void main(List<String> args) { | ||
print('Validating commit...'); | ||
|
||
// Run dart analyze | ||
final analyzeResult = Process.runSync('dart', ['analyze']); | ||
if (analyzeResult.exitCode != 0) { | ||
print('❌ Dart analyze failed. Please fix the issues.'); | ||
print(analyzeResult.stdout); | ||
exit(1); | ||
} | ||
|
||
// Run dart format | ||
final formatResult = | ||
Process.runSync('dart', ['format', '--set-exit-if-changed', '.']); | ||
if (formatResult.exitCode != 0) { | ||
print('❌ Dart format failed. Please format your code.'); | ||
exit(1); | ||
} | ||
|
||
print('✅ Commit passed all validations.'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:io'; | ||
|
||
void main(List<String> args) { | ||
print('Validating commit message...'); | ||
|
||
if (args.isEmpty) { | ||
print('❌ No commit message file provided.'); | ||
exit(1); | ||
} | ||
|
||
final commitMessage = File(args[0]).readAsStringSync(); | ||
final regex = RegExp( | ||
r'^(feat|fix|hotfix|chore|test|refactor|release)(\([a-z0-9_-]+\))?: .{1,72}$'); | ||
|
||
if (!regex.hasMatch(commitMessage)) { | ||
print('❌ Commit message does not follow the required format.'); | ||
print('Format: <type>(<scope>): <short summary>'); | ||
print('Examples:'); | ||
print(' feat(auth): add OAuth 2.0 support'); | ||
print(' fix(payment): resolve rounding error'); | ||
exit(1); | ||
} | ||
|
||
print('✅ Commit message is valid.'); | ||
} |
Binary file added
BIN
+1.15 MB
open-feature-dart-server-sdk/.dart_tool/pub/bin/git_hooks/git_hooks.dart-3.5.4.snapshot
Binary file not shown.
Oops, something went wrong.