Skip to content

Commit 4836237

Browse files
authored
Merge branch 'main' into copilot/fix-783
2 parents 1adde8a + 7402b68 commit 4836237

28 files changed

+574
-343
lines changed

.github/copilot-instructions.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1-
We use Chef Cookstyle to lint our Chef cookbooks. We use Test Kitchen to integration test our cookbooks. Test cookbooks are in the test/cookbooks directory. We keep documentation in README.md and the documentation folder. When suggestion improvements ignore the test directory.
1+
# Copilot Instructions for Sous Chefs Cookbooks
2+
3+
## Repository Overview
4+
5+
**Chef cookbook** for managing software installation and configuration. Part of the Sous Chefs cookbook ecosystem.
6+
7+
**Key Facts:** Ruby-based, Chef >= 16 required, supports various OS platforms (check metadata.rb, kitchen.yml and .github/workflows/ci.yml for which platforms to specifically test)
8+
9+
## Project Structure
10+
11+
**Critical Paths:**
12+
- `recipes/` - Chef recipes for cookbook functionality (if this is a recipe-driven cookbook)
13+
- `resources/` - Custom Chef resources with properties and actions (if this is a resource-driven cookbook)
14+
- `spec/` - ChefSpec unit tests
15+
- `test/integration/` - InSpec integration tests (tests all platforms supported)
16+
- `test/cookbooks/` or `test/fixtures/` - Example cookbooks used during testing that show good examples of custom resource usage
17+
- `attributes/` - Configuration for recipe driven cookbooks (not applicable to resource cookbooks)
18+
- `libraries/` - Library helpers to assist with the cookbook. May contain multiple files depending on complexity of the cookbook.
19+
- `templates/` - ERB templates that may be used in the cookbook
20+
- `files/` - files that may be used in the cookbook
21+
- `metadata.rb`, `Berksfile` - Cookbook metadata and dependencies
22+
23+
## Build and Test System
24+
25+
### Environment Setup
26+
**MANDATORY:** Install Chef Workstation first - provides chef, berks, cookstyle, kitchen tools.
27+
28+
### Essential Commands (strict order)
29+
```bash
30+
berks install # Install dependencies (always first)
31+
cookstyle # Ruby/Chef linting
32+
yamllint . # YAML linting
33+
markdownlint-cli2 '**/*.md' # Markdown linting
34+
chef exec rspec # Unit tests (ChefSpec)
35+
# Integration tests will be done via the ci.yml action. Do not run these. Only check the action logs for issues after CI is done running.
36+
```
37+
38+
### Critical Testing Details
39+
- **Kitchen Matrix:** Multiple OS platforms × software versions (check kitchen.yml for specific combinations)
40+
- **Docker Required:** Integration tests use Dokken driver
41+
- **CI Environment:** Set `CHEF_LICENSE=accept-no-persist`
42+
- **Full CI Runtime:** 30+ minutes for complete matrix
43+
44+
### Common Issues and Solutions
45+
- **Always run `berks install` first** - most failures are dependency-related
46+
- **Docker must be running** for kitchen tests
47+
- **Chef Workstation required** - no workarounds, no alternatives
48+
- **Test data bags needed** (optional for some cookbooks) in `test/integration/data_bags/` for convergence
49+
50+
## Development Workflow
51+
52+
### Making Changes
53+
1. Edit recipes/resources/attributes/templates/libraries
54+
2. Update corresponding ChefSpec tests in `spec/`
55+
3. Also update any InSpec tests under test/integration
56+
4. Ensure cookstyle and rspec passes at least. You may run `cookstyle -a` to automatically fix issues if needed.
57+
5. Also always update all documentation found in README.md and any files under documentation/*
58+
6. **Always update CHANGELOG.md** (required by Dangerfile) - Make sure this conforms with the Sous Chefs changelog standards.
59+
60+
### Pull Request Requirements
61+
- **PR description >10 chars** (Danger enforced)
62+
- **CHANGELOG.md entry** for all code changes
63+
- **Version labels** (major/minor/patch) required
64+
- **All linters must pass** (cookstyle, yamllint, markdownlint)
65+
- **Test updates** needed for code changes >5 lines and parameter changes that affect the code logic
66+
67+
## Chef Cookbook Patterns
68+
69+
### Resource Development
70+
- Custom resources in `resources/` with properties and actions
71+
- Include comprehensive ChefSpec tests for all actions
72+
- Follow Chef resource DSL patterns
73+
74+
### Recipe Conventions
75+
- Use `include_recipe` for modularity
76+
- Handle platforms with `platform_family?` conditionals
77+
- Use encrypted data bags for secrets (passwords, SSL certs)
78+
- Leverage attributes for configuration with defaults
79+
80+
### Testing Approach
81+
- **ChefSpec (Unit):** Mock dependencies, test recipe logic in `spec/`
82+
- **InSpec (Integration):** Verify actual system state in `test/integration/inspec/` - InSpec files should contain proper inspec.yml and controls directories so that it could be used by other suites more easily.
83+
- One test file per recipe, use standard Chef testing patterns
84+
85+
## Trust These Instructions
86+
87+
These instructions are validated for Sous Chefs cookbooks. **Do not search for build instructions** unless information here fails.
88+
89+
**Error Resolution Checklist:**
90+
1. Verify Chef Workstation installation
91+
2. Confirm `berks install` completed successfully
92+
3. Ensure Docker is running for integration tests
93+
4. Check for missing test data dependencies
94+
95+
The CI system uses these exact commands - following them matches CI behavior precisely.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copilot Project Instructions: postgresql Cookbook (Specific)
2+
3+
This file provides cookbook-specific instructions for Copilot and other AI coding assistants. It supplements, but does not duplicate, the general instructions in `.github/copilot-instructions.md`.
4+
5+
## Cookbook Purpose
6+
7+
- The `postgresql` cookbook manages installation, configuration, and access control for PostgreSQL database servers.
8+
- It provides custom Chef resources for PostgreSQL installation, service management, user/database creation, access control, and configuration.
9+
- Supports multiple PostgreSQL versions and major Linux distributions (see `metadata.rb`, `kitchen.yml`).
10+
11+
## Key Custom Resources
12+
13+
- `postgresql_install`: Installs and initializes PostgreSQL server.
14+
- `postgresql_service`: Manages the PostgreSQL system service (start, stop, restart, enable, etc.).
15+
- `postgresql_access`: Manages entries in `pg_hba.conf` for access control.
16+
- `postgresql_user`: Creates, updates, and manages PostgreSQL users and roles.
17+
- `postgresql_database`: Creates and manages databases.
18+
- `postgresql_config`: Manages configuration files.
19+
- `postgresql_extension`, `postgresql_ident`, `postgresql_role`: Additional resources for advanced PostgreSQL features.
20+
21+
## Cookbook-Specific Patterns
22+
23+
- All access control changes (`postgresql_access`) must ensure the config file is written before triggering a service restart.
24+
- Helper modules in `libraries/` are used for parsing and manipulating PostgreSQL config files.
25+
- Example usage and test coverage for all resources is found in `test/cookbooks/test/recipes/`.
26+
- Templates for configuration files are located in `templates/default/`.
27+
28+
## Testing and Validation
29+
30+
- Integration tests cover multiple OS and PostgreSQL versions (see `.kitchen/logs/` for matrix).
31+
- Example test recipes demonstrate resource usage and edge cases (e.g., usernames with dashes, multiple databases/users, LDAP auth).
32+
33+
## Documentation
34+
35+
- Resource documentation is in `documentation/` and includes usage examples and property details for each resource.
36+
37+
## Special Notes
38+
39+
- This cookbook is resource-driven; recipes are only used for testing and examples.
40+
- All changes must maintain idempotency and proper notification sequencing for service restarts.
41+
- Do not bypass resource logic—always use the provided custom resources for PostgreSQL management.
42+
43+
For general build, test, and workflow instructions, refer to `.github/copilot-instructions.md`.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name: ci
88

99
jobs:
1010
lint-unit:
11-
uses: sous-chefs/.github/.github/workflows/lint-unit.yml@4.0.0
11+
uses: sous-chefs/.github/.github/workflows/lint-unit.yml@5.0.3
1212
permissions:
1313
actions: write
1414
checks: write
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: conventional-commits
3+
4+
"on":
5+
pull_request:
6+
types:
7+
- opened
8+
- reopened
9+
- edited
10+
- synchronize
11+
12+
jobs:
13+
conventional-commits:
14+
uses: sous-chefs/.github/.github/workflows/[email protected]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: 'Copilot Setup Steps'
3+
4+
"on":
5+
workflow_dispatch:
6+
push:
7+
paths:
8+
- .github/workflows/copilot-setup-steps.yml
9+
pull_request:
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
13+
jobs:
14+
copilot-setup-steps:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v5
21+
- name: Install Chef
22+
uses: actionshub/chef-install@main
23+
- name: Install cookbooks
24+
run: berks install
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: prevent-file-change
3+
4+
"on":
5+
pull_request:
6+
types:
7+
- opened
8+
- reopened
9+
- edited
10+
- synchronize
11+
12+
jobs:
13+
prevent-file-change:
14+
uses: sous-chefs/.github/.github/workflows/[email protected]
15+
secrets:
16+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: release
3+
4+
"on":
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
packages: write
14+
attestations: write
15+
id-token: write
16+
17+
jobs:
18+
release:
19+
uses: sous-chefs/.github/.github/workflows/[email protected]
20+
secrets:
21+
token: ${{ secrets.PORTER_GITHUB_TOKEN }}
22+
supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }}
23+
supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }}

.markdownlint-cli2.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ config:
33
line-length: false # MD013
44
no-duplicate-heading: false # MD024
55
reference-links-images: false # MD052
6+
no-multiple-blanks:
7+
maximum: 2
68
ignores:
79
- .github/copilot-instructions.md

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "12.4.0"
3+
}

0 commit comments

Comments
 (0)