Skip to content

Commit a1d4545

Browse files
authored
fix: Update tooling (#228)
* fix: Update tooling - fix(tooling): Add mise and rubocop * chore(tooling): Add lefthook and fix rubocop warnings --------- Signed-off-by: Dan Webb <dan.webb@damacus.io>
1 parent b5f06fd commit a1d4545

File tree

11 files changed

+552
-62
lines changed

11 files changed

+552
-62
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
name: release
33

4+
45
"on":
56
push:
6-
branches:
7-
- main
7+
branches: [main]
88

99
permissions:
1010
contents: write
@@ -16,8 +16,10 @@ permissions:
1616

1717
jobs:
1818
release:
19-
uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@5.0.8
19+
uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@main
2020
secrets:
2121
token: ${{ secrets.PORTER_GITHUB_TOKEN }}
2222
supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }}
2323
supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }}
24+
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
25+
slack_channel_id: ${{ secrets.SLACK_CHANNEL_ID }}

.mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[env]
2+
_.path = "/opt/chef-workstation/bin"

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
- cookstyle

.windsurf/workflows/kitchen-fix.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
description: Run all kitchen suites and fix failures iteratively
3+
auto_execution_mode: 3
4+
---
5+
6+
# Kitchen Test and Fix Workflow
7+
8+
This workflow runs all Test Kitchen suites, aggregates failures, and iteratively fixes common issues.
9+
10+
## Steps
11+
12+
### 1. Get Your Bearings
13+
14+
Run `kitchen list` to see all available test suites and their current state.
15+
16+
```bash
17+
chef exec kitchen list
18+
```
19+
20+
Review the output to understand:
21+
22+
- Which suites exist (installer-mysql, installer-postgresql, standalone-mysql, standalone-postgresql)
23+
- Which platforms are configured
24+
- Current state of any existing instances
25+
26+
### 2. Run Kitchen Tests
27+
28+
Run all kitchen tests in parallel with destroy on completion:
29+
30+
```bash
31+
# Run a single suite first to validate
32+
chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always
33+
34+
# Or run all tests (this takes a long time)
35+
chef exec kitchen test --concurrency=4 --destroy=always
36+
```
37+
38+
For faster iteration, test one platform per suite first:
39+
40+
```bash
41+
chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always
42+
chef exec kitchen test installer-postgresql-ubuntu-2404 --destroy=always
43+
chef exec kitchen test standalone-mysql-ubuntu-2404 --destroy=always
44+
chef exec kitchen test standalone-postgresql-ubuntu-2404 --destroy=always
45+
```
46+
47+
### 3. Aggregate Failures
48+
49+
When tests fail, collect and categorize the errors:
50+
51+
1. **Converge failures** - Recipe compilation or resource execution errors
52+
2. **Verify failures** - InSpec/Serverspec test failures
53+
3. **Platform-specific failures** - Issues only on certain OS families
54+
55+
For each failure, note:
56+
57+
- Suite name
58+
- Platform
59+
- Error message
60+
- Stack trace location
61+
62+
### 4. Apply Common Fixes
63+
64+
Address failures by category:
65+
66+
#### Converge Failures
67+
68+
- Check recipe syntax and resource availability
69+
- Verify cookbook dependencies in `metadata.rb` and `Berksfile`
70+
- Review attribute precedence issues
71+
- Check for deprecated Chef APIs
72+
73+
#### Verify Failures
74+
75+
- Review test expectations in `test/integration/*/serverspec/`
76+
- Ensure services are running and ports are listening
77+
- Check file permissions and ownership
78+
79+
#### Platform-Specific Failures
80+
81+
- Add platform conditionals where needed
82+
- Check package names differ between distros
83+
- Verify service names (systemd vs init)
84+
85+
### 5. Iterate
86+
87+
After applying fixes:
88+
89+
// turbo
90+
91+
1. Re-run the failing tests:
92+
93+
```bash
94+
chef exec kitchen test <suite-platform> --destroy=always
95+
```
96+
97+
1. If new failures appear, return to step 3
98+
2. Continue until all tests pass
99+
100+
### 6. Verify All Suites Pass
101+
102+
Once individual fixes are applied, run the full test matrix:
103+
104+
```bash
105+
chef exec kitchen test --concurrency=4 --destroy=always
106+
```
107+
108+
### 7. Cleanup
109+
110+
Destroy any remaining kitchen instances:
111+
112+
// turbo
113+
114+
```bash
115+
chef exec kitchen destroy
116+
```
117+
118+
## Common Issues Reference
119+
120+
| Error | Cause | Fix |
121+
|-----------------------|---------------------------------|---------------------------------|
122+
| `undefined method` | Missing cookbook dependency | Add to `metadata.rb` depends |
123+
| `package not found` | Wrong package name for platform | Use platform conditionals |
124+
| `service not running` | Service failed to start | Check logs, add retries |
125+
| `port not listening` | App not configured correctly | Review configuration templates |
126+
| `Chef::Platform.set` | Deprecated API in dependency | Update cookbook version or stub |

kitchen.yml

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,22 @@ suites:
3535
- name: client
3636
run_list:
3737
- recipe[sql_server::default]
38-
attributes: {sql_server: {accept_eula: true}}
38+
attributes: { sql_server: { accept_eula: true } }
3939
verifier:
4040
controls:
4141
- client
42-
- name: server2012
43-
run_list:
44-
- recipe[sql_server::server]
45-
attributes: {sql_server: {accept_eula: true, version: 2012, server_sa_password: Supersecurepassword123}}
46-
verifier:
47-
controls:
48-
- server
49-
inputs:
50-
version: 2012
5142
- name: server2016
5243
run_list:
5344
- recipe[sql_server::server]
54-
attributes: {sql_server: {accept_eula: true, version: 2016, server_sa_password: Supersecurepassword123}}
45+
attributes:
46+
{
47+
sql_server:
48+
{
49+
accept_eula: true,
50+
version: 2016,
51+
server_sa_password: Supersecurepassword123,
52+
},
53+
}
5554
verifier:
5655
controls:
5756
- server
@@ -60,7 +59,15 @@ suites:
6059
- name: server2017
6160
run_list:
6261
- recipe[sql_server::server]
63-
attributes: {sql_server: {accept_eula: true, version: 2017, server_sa_password: Supersecurepassword123}}
62+
attributes:
63+
{
64+
sql_server:
65+
{
66+
accept_eula: true,
67+
version: 2017,
68+
server_sa_password: Supersecurepassword123,
69+
},
70+
}
6471
verifier:
6572
controls:
6673
- server
@@ -69,7 +76,15 @@ suites:
6976
- name: server2019
7077
run_list:
7178
- recipe[sql_server::server]
72-
attributes: {sql_server: {accept_eula: true, version: 2019, server_sa_password: Supersecurepassword123}}
79+
attributes:
80+
{
81+
sql_server:
82+
{
83+
accept_eula: true,
84+
version: 2019,
85+
server_sa_password: Supersecurepassword123,
86+
},
87+
}
7388
verifier:
7489
controls:
7590
- server
@@ -78,12 +93,37 @@ suites:
7893
includes:
7994
- windows-2016
8095
- windows-2019
96+
- name: server2022
97+
run_list:
98+
- recipe[sql_server::server]
99+
attributes:
100+
{
101+
sql_server:
102+
{
103+
accept_eula: true,
104+
version: 2022,
105+
server_sa_password: Supersecurepassword123,
106+
},
107+
}
108+
verifier:
109+
controls:
110+
- server
111+
inputs:
112+
version: 2022
81113
- name: install
82114
run_list:
83115
- recipe[test::install]
84116
verifier:
85117
controls:
86118
- server
87119
inputs:
88-
version: 2012
89-
attributes: {sql_server: {accept_eula: true, version: 2012, server_sa_password: Supersecurepassword123}}
120+
version: 2022
121+
attributes:
122+
{
123+
sql_server:
124+
{
125+
accept_eula: true,
126+
version: 2022,
127+
server_sa_password: Supersecurepassword123,
128+
},
129+
}

lefthook.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pre-commit:
2+
commands:
3+
cookstyle:
4+
run: chef exec cookstyle
5+
rspec:
6+
run: chef exec rspec
7+
yamllint:
8+
run: yamllint .
9+
markdownlint:
10+
run: markdownlint-cli2 "**/*.md" --fix

libraries/helper.rb

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@ module Helper
2626

2727
def self.reg_version_string(version)
2828
case version.to_s # to_s to make sure someone didn't pass us an int
29-
when '2012' then 'MSSQL11.'
3029
when '2016' then 'MSSQL13.'
3130
when '2017' then 'MSSQL14.'
3231
when '2019' then 'MSSQL15.'
3332
when '2022' then 'MSSQL16.'
3433
when '2025' then 'MSSQL17.'
35-
else raise "Unsupported sql_server version '#{version}'. Please open a PR to add support for this version."
34+
else raise "Unsupported sql_server version '#{version}'. Supported versions: 2016, 2017, 2019, 2022, 2025"
3635
end
3736
end
3837

3938
def self.install_dir_version(version)
4039
case version.to_s # to_s to make sure someone didn't pass us an int
41-
when '2012' then '110'
4240
when '2016' then '130'
4341
when '2017' then '140'
4442
when '2019' then '150'
4543
when '2022' then '160'
4644
when '2025' then '170'
47-
else raise "SQL Server version #{version} not supported. Please open a PR to add support for this version."
45+
else raise "SQL Server version #{version} not supported. Supported versions: 2016, 2017, 2019, 2022, 2025"
4846
end
4947
end
5048

@@ -54,53 +52,38 @@ def self.firewall_rule_enabled?(rule_name = nil)
5452
end
5553

5654
def self.sql_server_url(version, x86_64)
57-
if x86_64
58-
case version.to_s # to_s to make sure someone didn't pass us an int
59-
when '2012' then 'https://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPR_x64_ENU.exe'
60-
when '2016' then 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe'
61-
when '2017' then 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe'
62-
when '2019' then 'https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe'
63-
when '2022' then 'https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe'
64-
when '2025' then 'https://download.microsoft.com/download/7ab8f535-7eb8-4b16-82eb-eca0fa2d38f3/SQL2025-SSEI-Expr.exe'
65-
end
66-
else
67-
case version.to_s
68-
when '2012' then 'https://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x86/SQLEXPR_x86_ENU.exe'
69-
end
55+
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions
56+
57+
case version.to_s # to_s to make sure someone didn't pass us an int
58+
when '2016' then 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe'
59+
when '2017' then 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe'
60+
when '2019' then 'https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe'
61+
when '2022' then 'https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe'
62+
when '2025' then nil # URL not yet available - use source_url property
7063
end
7164
end
7265

7366
def self.sql_server_package_name(version, x86_64)
74-
if x86_64
75-
case version.to_s # to_s to make sure someone didn't pass us an int
76-
when '2012' then 'Microsoft SQL Server 2012 (64-bit)'
77-
when '2016' then 'Microsoft SQL Server 2016 (64-bit)'
78-
when '2017' then 'Microsoft SQL Server 2017 (64-bit)'
79-
when '2019' then 'Microsoft SQL Server 2019 (64-bit)'
80-
when '2022' then 'Microsoft SQL Server 2022 (64-bit)'
81-
when '2025' then 'Microsoft SQL Server 2025 (64-bit)'
82-
end
83-
else
84-
case version.to_s
85-
when '2012' then 'Microsoft SQL Server 2012 (32-bit)'
86-
end
67+
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions
68+
69+
case version.to_s # to_s to make sure someone didn't pass us an int
70+
when '2016' then 'Microsoft SQL Server 2016 (64-bit)'
71+
when '2017' then 'Microsoft SQL Server 2017 (64-bit)'
72+
when '2019' then 'Microsoft SQL Server 2019 (64-bit)'
73+
when '2022' then 'Microsoft SQL Server 2022 (64-bit)'
74+
when '2025' then 'Microsoft SQL Server 2025 (64-bit)'
8775
end
8876
end
8977

9078
def self.sql_server_checksum(version, x86_64)
91-
if x86_64
92-
case version.to_s # to_s to make sure someone didn't pass us an int
93-
when '2012' then '7f5e3d40b85fba2da5093e3621435c209c4ac90d34219bab8878e93a787cf29f'
94-
when '2016' then '2A5B64AE64A8285C024870EC4643617AC5146894DD59DD560E75CEA787BF9333'
95-
when '2017' then 'F857FF82145E196BF85AF32EEB0193FE38302E57B30BEB54E513630C60D83E0D'
96-
when '2019' then 'bea033e778048748eb1c87bf57597f7f5449b6a15bac55ddc08263c57f7a1ca8'
97-
when '2022' then '36e0ec2ac3dd60f496c99ce44722c629209ea7302a2ce9cbfd1e42a73510d7b6'
98-
when '2025' then '1c677a33b318481c3217128835f8405cf0026621dcd04b13eb6cb0982e823f27'
99-
end
100-
else
101-
case version.to_s
102-
when '2012' then '9bdd6a7be59c00b0201519b9075601b1c18ad32a3a166d788f3416b15206d6f5'
103-
end
79+
return unless x86_64 # Only x86_64 is supported for modern SQL Server versions
80+
81+
case version.to_s # to_s to make sure someone didn't pass us an int
82+
when '2016' then '2A5B64AE64A8285C024870EC4643617AC5146894DD59DD560E75CEA787BF9333'
83+
when '2017' then 'F857FF82145E196BF85AF32EEB0193FE38302E57B30BEB54E513630C60D83E0D'
84+
when '2019' then 'bea033e778048748eb1c87bf57597f7f5449b6a15bac55ddc08263c57f7a1ca8'
85+
when '2022' then '36e0ec2ac3dd60f496c99ce44722c629209ea7302a2ce9cbfd1e42a73510d7b6'
86+
when '2025' then nil # Checksum not yet available - use package_checksum property
10487
end
10588
end
10689
end

resources/configure.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
unified_mode true
2020

2121
property :reg_version, String
22-
property :version, [Integer, String], default: '2012'
22+
property :version, [Integer, String], default: '2022'
2323
property :tcp_enabled, [true, false], default: true
2424
property :sql_port, Integer, default: 1433
2525
property :tcp_dynamic_ports, String, default: ''

0 commit comments

Comments
 (0)