Skip to content

Commit ce923a9

Browse files
authored
Merge branch 'main' into copilot/fix-400
2 parents fa4b59e + 96c454e commit ce923a9

154 files changed

Lines changed: 5286 additions & 2094 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
^renovate\.json$
3636
^tests/testthat/helper-sync\.R$
3737
^index\.md$
38+
^AGENTS\.md$
3839
^CLAUDE\.md$
40+
^DEVCONTAINER\.md$
3941
^\.venv$
4042
^\.claude$
4143
^\.devcontainer$
44+
^air\.toml$

.claude/settings.json

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
{
2-
"tools": {
3-
"bash": {
4-
"allowedCommands": [
5-
"devcontainer up --workspace-folder .",
6-
"devcontainer exec --workspace-folder . *",
7-
"devcontainer build --workspace-folder .",
8-
"devcontainer --version",
9-
"touch *"
10-
],
11-
"requireConfirmation": false
12-
}
2+
"permissions": {
3+
"allow": [
4+
"Edit(*)",
5+
"Write(*)",
6+
"Bash(touch:*)",
7+
"Bash(devcontainer up:*)",
8+
"Bash(devcontainer exec:*)",
9+
"Bash(devcontainer build:*)",
10+
"Bash(devcontainer --version:*)",
11+
"WebFetch(domain:docs.anthropic.com)",
12+
"Bash(touch:*)",
13+
"Bash(rm:*)"
14+
],
15+
"defaultMode": "acceptEdits"
1316
},
1417
"hooks": {
15-
"bash": {
16-
"pre": "devcontainer exec --workspace-folder . bash -c"
17-
}
18-
}
18+
"PreToolUse": [
19+
{
20+
"matcher": "^Bash[(devcontainer.*[)]$",
21+
"hooks": [
22+
{
23+
"type": "command",
24+
"command": "devcontainer exec --workspace-folder . echo ok"
25+
}
26+
]
27+
}
28+
]
29+
},
30+
"$schema": "https://json.schemastore.org/claude-code-settings.json"
1931
}

.claude/settings.local.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.devcontainer/README.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Devcontainer Setup for dm Package
2+
3+
This directory contains the devcontainer configuration for the dm package development environment.
4+
5+
## Files
6+
7+
- `devcontainer.json` - Main devcontainer configuration
8+
- `docker-compose.yml` - Docker Compose file defining the development services
9+
- `test-postgres.R` - Script to test PostgreSQL connectivity
10+
11+
## Services
12+
13+
### PostgreSQL Database
14+
15+
- **Image**: `postgres:latest` (latest PostgreSQL version)
16+
- **Container**: `devcontainer-postgres`
17+
- **Port**: 5432
18+
- **Database**: test
19+
- **User**: compose
20+
- **Password**: YourStrong!Passw0rd
21+
22+
### MariaDB Database
23+
24+
- **Image**: `mariadb:latest` (latest MariaDB version)
25+
- **Container**: `devcontainer-mariadb`
26+
- **Port**: 3306
27+
- **Database**: test
28+
- **User**: compose
29+
- **Password**: YourStrong!Passw0rd
30+
31+
### SQL Server Database
32+
33+
- **Image**: `mcr.microsoft.com/mssql/server:2022-latest` (SQL Server 2022 Express)
34+
- **Container**: `devcontainer-mssql`
35+
- **Port**: 1433
36+
- **Database**: test (created automatically)
37+
- **User**: SA
38+
- **Password**: YourStrong!Passw0rd
39+
40+
### Features
41+
42+
- Socket connections enabled via shared volume (`/var/run/postgresql`)
43+
- Network connections available on standard ports (5432 for PostgreSQL, 3306 for MariaDB, 1433 for SQL Server)
44+
- Environment variables pre-configured for easy R connections
45+
- Health checks ensure databases are ready before starting dev environment
46+
- Service-specific host environment variables for targeted testing
47+
48+
## Usage
49+
50+
1. Open the project in VS Code
51+
2. When prompted, reopen in devcontainer (or use Command Palette > "Dev Containers: Reopen in Container")
52+
3. All database services (PostgreSQL, MariaDB, SQL Server) will start automatically
53+
4. Test connectivity by running: `Rscript .devcontainer/test-postgres.R`
54+
55+
### Running Tests with Different Backends
56+
57+
```bash
58+
# Test with PostgreSQL (default)
59+
DM_TEST_SRC=postgres R -e 'testthat::test_local()'
60+
61+
# Test with MariaDB
62+
DM_TEST_SRC=maria R -e 'testthat::test_local()'
63+
64+
# Test with SQL Server (requires ODBC drivers)
65+
DM_TEST_SRC=mssql R -e 'testthat::test_local()'
66+
67+
# Test with data frames (no database)
68+
DM_TEST_SRC=df R -e 'testthat::test_local()'
69+
```
70+
71+
## Database Connection in R
72+
73+
The devcontainer environment supports multiple connection methods:
74+
75+
### PostgreSQL
76+
77+
```r
78+
# Using environment variables (recommended)
79+
con <- DBI::dbConnect(RPostgres::Postgres())
80+
81+
# Using explicit parameters
82+
con <- DBI::dbConnect(
83+
RPostgres::Postgres(),
84+
host = "postgres",
85+
port = 5432,
86+
user = "compose",
87+
password = "YourStrong!Passw0rd",
88+
dbname = "test"
89+
)
90+
91+
# Using socket connection (if available)
92+
con <- DBI::dbConnect(
93+
RPostgres::Postgres(),
94+
host = "/var/run/postgresql",
95+
user = "compose",
96+
dbname = "test"
97+
)
98+
```
99+
100+
### MariaDB
101+
102+
```r
103+
# Using explicit parameters
104+
con <- DBI::dbConnect(
105+
RMariaDB::MariaDB(),
106+
host = "mariadb",
107+
port = 3306,
108+
username = "compose",
109+
password = "YourStrong!Passw0rd",
110+
dbname = "test"
111+
)
112+
```
113+
114+
### SQL Server
115+
116+
```r
117+
# Using explicit parameters (requires ODBC drivers)
118+
con <- DBI::dbConnect(
119+
odbc::odbc(),
120+
driver = "ODBC Driver 18 for SQL Server",
121+
server = "mssql",
122+
database = "test",
123+
uid = "SA",
124+
pwd = "YourStrong!Passw0rd",
125+
port = 1433,
126+
TrustServerCertificate = "yes"
127+
)
128+
```
129+
130+
## Environment Variables
131+
132+
The following environment variables are set in the devcontainer:
133+
134+
### PostgreSQL
135+
136+
- `PGHOST=postgres`
137+
- `PGPORT=5432`
138+
- `PGUSER=compose`
139+
- `PGPASSWORD=YourStrong!Passw0rd`
140+
- `PGDATABASE=test`
141+
- `PGSOCKET=/var/run/postgresql`
142+
143+
### MariaDB
144+
145+
- `MYSQL_HOST=mariadb`
146+
- `MYSQL_PORT=3306`
147+
- `MYSQL_USER=compose`
148+
- `MYSQL_PASSWORD=YourStrong!Passw0rd`
149+
- `MYSQL_DATABASE=test`
150+
151+
### SQL Server
152+
153+
- `MSSQL_HOST=mssql`
154+
- `MSSQL_PORT=1433`
155+
- `MSSQL_USER=SA`
156+
- `MSSQL_PASSWORD=YourStrong!Passw0rd`
157+
- `MSSQL_DATABASE=test`
158+
159+
### Testing
160+
161+
- `DM_TEST_POSTGRES_HOST=postgres` (service-specific, takes precedence)
162+
- `DM_TEST_MARIA_HOST=mariadb` (service-specific, takes precedence)
163+
- `DM_TEST_MSSQL_HOST=mssql` (service-specific, takes precedence)
164+
165+
## Troubleshooting
166+
167+
1. **Database not starting**: Check if ports 5432 (PostgreSQL) or 3306 (MariaDB) are already in use on your host
168+
2. **Connection failures**: Run the test script to diagnose connection issues
169+
3. **Permission issues**: The PostgreSQL socket directory is configured with 0777 permissions
170+
4. **Container conflicts**: Ensure no other database containers are running with the same names
171+
5. **Environment variables not updated**: Use `devcontainer up --workspace-folder . --remove-existing-container` to recreate containers
172+
173+
## Notes
174+
175+
- Database data is persisted in Docker volumes (`postgres-data`, `mariadb-data`)
176+
- Socket connections are available for PostgreSQL through the shared `postgres-socket` volume
177+
- PostgreSQL includes `pg_stat_statements` extension for performance monitoring
178+
- All PostgreSQL SQL statements are logged for development debugging
179+
- MariaDB is configured with health checks to ensure availability before tests run
180+
- Service-specific environment variables allow targeted testing of individual database backends

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "dm R Development",
3-
"image": "ghcr.io/cynkra/docker-images/ubuntu24-rig-rrel-dc-dt-dm:latest",
3+
"dockerComposeFile": "./docker-compose.yml",
4+
"service": "app",
45
"features": {
56
"ghcr.io/devcontainers/features/git:1": {}
67
},
@@ -13,6 +14,5 @@
1314
}
1415
},
1516
"remoteUser": "ubuntu",
16-
"workspaceFolder": "/home/ubuntu/workspace",
17-
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ubuntu/workspace,type=bind,consistency=cached"
17+
"workspaceFolder": "/home/ubuntu/workspace"
1818
}

0 commit comments

Comments
 (0)