-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add precommit and fix postgres job (#418)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced a pre-commit workflow to automate checks before code merges. - Added a section in the README for testing packages locally. - **Improvements** - Enhanced PostgreSQL initialization script for better user and role management. - Updated documentation for Managed PostgreSQL Service with improved formatting and additional backup parameters. - Integrated pre-commit hooks for maintaining code quality in YAML and Markdown files. - Added a new target in the installer Makefile to run pre-checks before building images. - **Bug Fixes** - Adjusted formatting in various README files to ensure consistent presentation. - **Chores** - Updated image reference to use the latest version in configuration files. - Updated versioning for various packages in the versions map. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
9 changed files
with
110 additions
and
18 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,35 @@ | ||
name: Pre-Commit Checks | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install pre-commit | ||
run: pip install pre-commit | ||
|
||
- name: Run pre-commit hooks | ||
run: | | ||
git fetch origin main || git fetch origin master | ||
base_commit=$(git rev-parse --verify origin/main || git rev-parse --verify origin/master || echo "") | ||
if [ -z "$base_commit" ]; then | ||
files=$(git ls-files '*.yaml' '*.md') | ||
else | ||
files=$(git diff --name-only "$base_commit" -- '*.yaml' '*.md') | ||
fi | ||
if [ -n "$files" ]; then | ||
echo "$files" | xargs pre-commit run --files | ||
else | ||
echo "No YAML or Markdown files to lint" | ||
fi |
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,16 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: mixed-line-ending | ||
args: [--fix=lf] | ||
- id: check-yaml | ||
exclude: packages/apps/postgres/templates/init-script.yaml | ||
args: [--unsafe] | ||
- repo: https://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.41.0 | ||
hooks: | ||
- id: markdownlint | ||
args: [--fix, --disable, MD013, MD041, --] |
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 @@ | ||
#!/bin/bash | ||
|
||
YQ_VERSION="v4.35.1" | ||
RED='\033[31m' | ||
RESET='\033[0m' | ||
|
||
check-yq-version() { | ||
current_version=$(yq -V | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+') | ||
if [ -z "$current_version" ]; then | ||
echo "yq is not installed or version cannot be determined." | ||
exit 1 | ||
fi | ||
echo "Current yq version: $current_version" | ||
|
||
if [ "$(printf '%s\n' "$YQ_VERSION" "$current_version" | sort -V | head -n1)" = "$YQ_VERSION" ]; then | ||
echo "Greater than or equal to $YQ_VERSION" | ||
else | ||
echo -e "${RED}ERROR: yq version less than $YQ_VERSION${RESET}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
check-yq-version |
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,9 @@ | ||
### How to test packages local | ||
|
||
```bash | ||
cd packages/core/installer | ||
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY | ||
make apply | ||
kubectl delete pod dashboard-redis-master-0 -n cozy-dashboard | ||
kubectl delete po -l app=source-controller -n cozy-fluxcd | ||
``` |
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
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