Skip to content

Commit 45fdec1

Browse files
Add GitHub Codespaces configuration for zero-setup development environment (#15)
* Initial plan * Add GitHub Codespaces configuration Co-authored-by: VaeterchenFrost <21226535+VaeterchenFrost@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: VaeterchenFrost <21226535+VaeterchenFrost@users.noreply.github.com>
1 parent 108b58f commit 45fdec1

File tree

4 files changed

+265
-0
lines changed

4 files changed

+265
-0
lines changed

.devcontainer/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# AdventOfCode Codespaces
2+
3+
This repository includes a GitHub Codespaces configuration for a complete development environment.
4+
5+
## Quick Start
6+
7+
1. Click the "Code" button on GitHub
8+
2. Select "Create codespace on main"
9+
3. Wait for the environment to set up (2-3 minutes)
10+
4. Open a PowerShell terminal and start coding!
11+
12+
## What's Included
13+
14+
### Languages & Runtimes
15+
- **PowerShell 7** - Primary language for AdventOfCode solutions
16+
- **Python 3.9+** - For utilities and Neo4j integration
17+
- **Conda** - Python environment management
18+
19+
### VS Code Extensions
20+
- PowerShell extension with syntax highlighting and debugging
21+
- Python extension with Pylance for enhanced development
22+
- GitHub Copilot for AI-assisted coding
23+
- Neo4j Cypher extension for graph queries
24+
- Jupyter notebooks support
25+
- Markdown and YAML editing support
26+
27+
### Development Tools
28+
- Git configuration
29+
- Neo4j Python driver for graph problems
30+
- All dependencies from `environment.yml`
31+
- Auto-setup of project in development mode
32+
33+
## Environment Setup
34+
35+
The codespace automatically:
36+
1. Installs all dependencies from `environment.yml`
37+
2. Sets up the project in development mode (`pip install -e .`)
38+
3. Creates a `.env` file from the template
39+
4. Configures PowerShell as the primary terminal
40+
5. Sets up helpful aliases and functions
41+
42+
## Usage Tips
43+
44+
### PowerShell Terminal
45+
- Use `aoc <year>` to quickly navigate to year folders (e.g., `aoc 2021`)
46+
- PowerShell 7 is set as the default terminal
47+
- All .ps1 files have proper syntax highlighting
48+
49+
### Python Development
50+
- Conda environment `aoc-martinroebke` is automatically activated
51+
- Neo4j drivers are pre-installed for graph challenges
52+
- Project is installed in development mode
53+
54+
### Environment Variables
55+
- Update `.env` file with your AOC session token for automatic input download
56+
- Neo4j credentials can be configured for graph-based solutions
57+
58+
## Port Forwarding
59+
60+
The following ports are automatically forwarded:
61+
- **7474**: Neo4j HTTP interface
62+
- **7687**: Neo4j Bolt protocol
63+
64+
## File Structure
65+
66+
```
67+
.devcontainer/
68+
├── devcontainer.json # Main configuration
69+
├── setup.sh # Post-creation setup script
70+
└── README.md # This file
71+
```
72+
73+
## Troubleshooting
74+
75+
- If conda environment activation fails, run: `conda activate aoc-martinroebke`
76+
- For PowerShell issues, ensure you're using the PowerShell terminal
77+
- Neo4j connection requires proper credentials in `.env` file
78+
79+
Happy coding! 🎄

.devcontainer/devcontainer.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"name": "AdventOfCode Development Environment",
3+
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
4+
5+
"features": {
6+
"ghcr.io/devcontainers/features/powershell:1": {
7+
"version": "latest"
8+
},
9+
"ghcr.io/devcontainers/features/python:1": {
10+
"version": "3.9"
11+
},
12+
"ghcr.io/devcontainers/features/conda:1": {
13+
"version": "latest"
14+
},
15+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
16+
"version": "latest"
17+
}
18+
},
19+
20+
"customizations": {
21+
"vscode": {
22+
"extensions": [
23+
"ms-vscode.powershell",
24+
"ms-python.python",
25+
"ms-python.vscode-pylance",
26+
"ms-toolsai.jupyter",
27+
"GitHub.copilot",
28+
"GitHub.copilot-chat",
29+
"ms-vscode.vscode-json",
30+
"redhat.vscode-yaml",
31+
"ms-vscode.vscode-markdown",
32+
"davidanson.vscode-markdownlint",
33+
"ms-python.autopep8",
34+
"ms-python.flake8",
35+
"neo4j.cypher",
36+
"ms-vscode.hexdump"
37+
],
38+
"settings": {
39+
"python.defaultInterpreterPath": "/opt/conda/bin/python",
40+
"python.condaPath": "/opt/conda/bin/conda",
41+
"python.terminal.activateEnvironment": true,
42+
"powershell.powerShellDefaultVersion": "PowerShell (x64)",
43+
"files.associations": {
44+
"*.ps1": "powershell"
45+
},
46+
"terminal.integrated.defaultProfile.linux": "pwsh",
47+
"terminal.integrated.profiles.linux": {
48+
"pwsh": {
49+
"path": "/usr/bin/pwsh",
50+
"args": []
51+
},
52+
"bash": {
53+
"path": "/bin/bash",
54+
"args": []
55+
}
56+
}
57+
}
58+
}
59+
},
60+
61+
"postCreateCommand": "bash .devcontainer/setup.sh",
62+
63+
"forwardPorts": [7474, 7687],
64+
"portsAttributes": {
65+
"7474": {
66+
"label": "Neo4j HTTP",
67+
"onAutoForward": "silent"
68+
},
69+
"7687": {
70+
"label": "Neo4j Bolt",
71+
"onAutoForward": "silent"
72+
}
73+
},
74+
75+
"containerEnv": {
76+
"SHELL": "/usr/bin/pwsh"
77+
},
78+
79+
"mounts": [
80+
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
81+
],
82+
83+
"remoteUser": "codespace"
84+
}

.devcontainer/setup.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
echo "🚀 Setting up AdventOfCode development environment..."
4+
5+
# Update system packages
6+
sudo apt-get update
7+
8+
# Install additional packages needed for this repository
9+
sudo apt-get install -y \
10+
curl \
11+
wget \
12+
git \
13+
vim \
14+
nano \
15+
tree
16+
17+
# Set up conda environment from environment.yml
18+
echo "📦 Setting up conda environment..."
19+
if [ -f "environment.yml" ]; then
20+
conda env create -f environment.yml --force
21+
conda activate aoc-martinroebke
22+
echo "conda activate aoc-martinroebke" >> ~/.bashrc
23+
echo "conda activate aoc-martinroebke" >> ~/.zshrc
24+
else
25+
echo "⚠️ environment.yml not found, installing basic Python dependencies..."
26+
pip install neo4j-python-driver numpy python-dotenv setuptools
27+
fi
28+
29+
# Install the project in development mode
30+
echo "🔧 Installing project in development mode..."
31+
pip install -e .
32+
33+
# Create .env file from template if it doesn't exist
34+
if [ -f ".env.template" ] && [ ! -f ".env" ]; then
35+
echo "📝 Creating .env file from template..."
36+
cp .env.template .env
37+
echo "✅ Created .env file. Please update it with your actual values."
38+
fi
39+
40+
# Set PowerShell as default shell for the user
41+
echo "🐚 Configuring PowerShell..."
42+
sudo chsh -s /usr/bin/pwsh codespace 2>/dev/null || echo "Note: Could not set PowerShell as default shell"
43+
44+
# Configure PowerShell profile
45+
mkdir -p ~/.config/powershell
46+
cat > ~/.config/powershell/profile.ps1 << 'EOF'
47+
# AdventOfCode PowerShell Profile
48+
Write-Host "🎄 Welcome to AdventOfCode Development Environment!" -ForegroundColor Green
49+
Write-Host "PowerShell 7 is ready for Advent of Code solutions!" -ForegroundColor Cyan
50+
51+
# Set location to repository root
52+
Set-Location $env:GITHUB_WORKSPACE
53+
54+
# Useful aliases for AdventOfCode development
55+
Set-Alias -Name ll -Value Get-ChildItem
56+
Set-Alias -Name python -Value python3
57+
58+
# Function to quickly navigate to year folders
59+
function Set-AocYear {
60+
param([int]$Year)
61+
$yearPath = if ($Year -eq 2021) { "_2021" } else { $Year.ToString() }
62+
if (Test-Path $yearPath) {
63+
Set-Location $yearPath
64+
Write-Host "📅 Switched to year $Year" -ForegroundColor Yellow
65+
} else {
66+
Write-Host "❌ Year $Year not found" -ForegroundColor Red
67+
}
68+
}
69+
Set-Alias -Name aoc -Value Set-AocYear
70+
71+
Write-Host "Use 'aoc <year>' to navigate to a specific year folder" -ForegroundColor Gray
72+
EOF
73+
74+
# Create a welcome message
75+
cat > ~/.motd << 'EOF'
76+
🎄 AdventOfCode Development Environment 🎄
77+
78+
Available tools:
79+
• PowerShell 7 - Primary language for solutions
80+
• Python 3.9+ - For utilities and graph problems
81+
• Conda - Python package management
82+
• Neo4j drivers - For graph-based challenges
83+
• VS Code Extensions- PowerShell, Python, Copilot
84+
85+
Quick start:
86+
• Use 'aoc <year>' in PowerShell to navigate to year folders
87+
• Update .env file with your AOC session token
88+
• Run solutions with './Day X Solution.ps1'
89+
90+
Happy coding! 🚀
91+
EOF
92+
93+
echo "✅ Setup complete! Environment is ready for AdventOfCode development."
94+
echo "🎄 Use PowerShell as your primary terminal for the best experience."

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ sprinkled with some Wolfram Mathematica 13 https://www.wolfram.com/engine/
77

88
Also adding some [Python&Neo4j](https://neo4j.com/docs/python-manual/current/get-started/) with [Neo4j Aura](https://console.neo4j.io/#how-to-connect) as well for graph-thematic days.
99

10+
## Quick Start with GitHub Codespaces
11+
12+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/VaeterchenFrost/AdventOfCode)
13+
14+
Click the badge above to start developing immediately in a fully configured environment! No local setup required.
15+
16+
## Local Development Setup
17+
1018
Install Python environment using
1119
`conda env create -f ./environment.yml`
1220

0 commit comments

Comments
 (0)