Skip to content

Commit 61e2c72

Browse files
Standardise files with files in sous-chefs/repo-management
Signed-off-by: kitchen-porter <board@sous-chefs.org>
1 parent aef2f8c commit 61e2c72

File tree

2 files changed

+86
-113
lines changed

2 files changed

+86
-113
lines changed

.github/copilot-instructions.md

Lines changed: 84 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,95 @@
1-
# Apache2 Chef Cookbook
1+
# Copilot Instructions for Sous Chefs Cookbooks
22

3-
This repository contains the Chef cookbook for Apache HTTP Server management. It provides Debian/Ubuntu style Apache configuration across multiple platforms with resources for managing modules, sites, configurations, and service lifecycle.
3+
## Repository Overview
44

5-
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
5+
**Chef cookbook** for managing software installation and configuration. Part of the Sous Chefs cookbook ecosystem.
66

7-
## Working Effectively
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)
88

9-
### Bootstrap Environment
10-
- Install Ruby 3.2+ with development tools:
11-
- `sudo apt update && sudo apt install -y ruby-bundler ruby-dev build-essential nodejs npm`
12-
- Install Chef development tools (user gems due to permission constraints):
13-
- `gem install --user-install berkshelf cookstyle chefspec`
14-
- `export PATH="$HOME/.local/share/gem/ruby/3.2.0/bin:$PATH"`
15-
- Install additional linting tools:
16-
- `npm install -g markdownlint-cli2`
9+
## Project Structure
1710

18-
**Environment Setup**: With the Copilot setup workflow (`.github/workflows/copilot-setup-steps.yml`), Chef Workstation and dependencies are automatically installed via GitHub Actions setup steps, enabling full Berkshelf functionality (`berks install` works with supermarket.chef.io access).
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
1922

20-
### Linting and Code Quality
21-
- **Cookstyle (Ruby linting)**: `cookstyle .` -- takes 5 seconds. NEVER use `--auto-correct` as it can introduce syntax errors.
22-
- **YAML linting**: `yamllint .` -- takes <1 second
23-
- **Markdown linting**: `markdownlint-cli2 "**/*.md"` -- takes 1 second
24-
- **CRITICAL**: Always run `cookstyle .` before committing. Currently shows 17 style offenses that should NOT be auto-corrected due to syntax risks.
23+
## Build and Test System
2524

26-
### Testing Status
27-
- **Unit Tests**: RSpec with ChefSpec works with Chef Workstation from setup workflow
28-
- **Integration Tests**: Test Kitchen available with Chef Workstation and container support
29-
- **CI Environment**: Uses GitHub Actions with Chef Workstation, Dokken containers, and matrix testing across platforms
30-
- **Available Validation**: Full linting (Cookstyle, YAML, Markdown), unit tests, and integration tests
25+
### Environment Setup
26+
**MANDATORY:** Install Chef Workstation first - provides chef, berks, cookstyle, kitchen tools.
3127

32-
### Build and Dependency Management
33-
- **Berkshelf**: `berks install` -- Works with Chef Workstation installed via setup workflow
34-
- **Dependencies**: Single dependency on `yum-epel` cookbook (defined in metadata.rb)
35-
- **Platforms Supported**: Debian, Ubuntu, RHEL, CentOS, Fedora, Amazon, Scientific, FreeBSD, SUSE, OpenSUSE, Arch
36-
- **Chef Version**: Requires Chef >= 15.3
37-
38-
## Validation Scenarios
39-
- **Cookstyle auto-correction available**: With Chef Workstation, `cookstyle --auto-correct` can be used safely
40-
- **Complete testing pipeline**: Lint, unit tests, and integration tests all available via setup workflow
41-
- **Full dependency resolution**: Berkshelf can install all cookbook dependencies from Chef Supermarket
42-
- **CI will run full integration tests**: 9 test suites across 13 platform combinations in GitHub Actions
43-
44-
## Common Tasks
45-
46-
### Repository Structure
47-
```
48-
/home/runner/work/apache2/apache2/
49-
├── resources/ # Chef resources (install.rb, service.rb, mod_*.rb, etc.)
50-
├── libraries/ # Helper functions (helpers.rb)
51-
├── templates/ # Configuration templates (.erb files)
52-
├── test/ # Test cookbooks and integration tests
53-
│ ├── cookbooks/test/ # Test recipes
54-
│ └── integration/ # InSpec integration tests
55-
├── spec/ # RSpec unit tests (ChefSpec)
56-
├── documentation/ # Resource documentation
57-
├── metadata.rb # Cookbook metadata and dependencies
58-
├── kitchen.yml # Test Kitchen configuration
59-
├── kitchen.dokken.yml # Docker-based testing config
60-
└── Berksfile # Berkshelf dependency management
61-
```
62-
63-
### Key Files to Reference
64-
- **metadata.rb**: Cookbook version, dependencies, supported platforms
65-
- **libraries/helpers.rb**: Platform-specific defaults and helper methods
66-
- **resources/install.rb**: Main Apache installation resource
67-
- **resources/service.rb**: Apache service management
68-
- **resources/mod_*.rb**: Apache module management resources
69-
- **test/cookbooks/test/recipes/**: Example usage patterns
70-
71-
### Workflow Commands
28+
### Essential Commands (strict order)
7229
```bash
73-
# Set up environment
74-
export PATH="$HOME/.local/share/gem/ruby/3.2.0/bin:$PATH"
75-
76-
# Lint everything before changes
77-
cookstyle .
78-
yamllint .
79-
markdownlint-cli2 "**/*.md"
80-
81-
# View test examples
82-
cat test/cookbooks/test/recipes/default.rb
83-
cat test/cookbooks/test/recipes/basic_site.rb
84-
85-
# Check integration test scenarios
86-
ls test/integration/*/controls/
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.
8736
```
8837

89-
### Resource Usage Examples
90-
See `test/cookbooks/test/recipes/` for working examples:
91-
- **Basic Apache**: `default.rb` - Install, configure service, manage default site
92-
- **SSL Configuration**: `mod_ssl.rb` - SSL module and site setup
93-
- **PHP Integration**: `php.rb` - PHP module configuration
94-
- **Custom Modules**: `module_template.rb` - Custom module management
95-
96-
### Platform-Specific Notes
97-
- **RHEL/CentOS**: Uses `httpd` service name, `/etc/httpd/` config path
98-
- **Debian/Ubuntu**: Uses `apache2` service name, `/etc/apache2/` config path
99-
- **FreeBSD**: Uses `apache24` service name
100-
- Helper functions in `libraries/helpers.rb` abstract platform differences
101-
102-
### Environment Capabilities
103-
- **Network access**: Full access to Chef Supermarket and external dependencies via GitHub Actions setup
104-
- **Chef Workstation**: Available via `actionshub/chef-install` action in setup workflow
105-
- **Unit tests**: ChefSpec and RSpec available with proper Chef Workstation installation
106-
- **Integration testing**: Available with Test Kitchen and container support
107-
- **Cookstyle auto-correction**: Safe to use with proper Chef environment
108-
109-
### CI Integration Notes
110-
- GitHub Actions uses `actionshub/chef-install` to install Chef Workstation
111-
- Runs on Ubuntu with Chef licensing: `CHEF_LICENSE: accept-no-persist`
112-
- Full matrix testing: 9 test suites × 13 platforms = 117 test combinations
113-
- Uses Dokken containers for fast, isolated testing environment
114-
- Shared workflow from sous-chefs/.github repository handles lint-unit phase
115-
116-
**TIMING EXPECTATIONS**:
117-
- Cookstyle linting: ~5 seconds
118-
- YAML linting: ~1 second
119-
- Markdown linting: ~1 second
120-
- Dependency resolution: Works with Berkshelf via setup workflow
121-
- Unit tests: Available with ChefSpec
122-
- Integration tests: Available with Test Kitchen and containers
123-
124-
**REMEMBER**: This cookbook manages Apache HTTP server across multiple platforms. Focus on resource definitions, template logic, and platform compatibility when making changes. The extensive CI matrix will validate functionality across all supported platforms.
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.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Standardise files with files in sous-chefs/repo-management
88

99
Standardise files with files in sous-chefs/repo-management
1010

11+
Standardise files with files in sous-chefs/repo-management
12+
1113
## 9.3.7 - *2025-09-04*
1214

1315
Standardise files with files in sous-chefs/repo-management

0 commit comments

Comments
 (0)