Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Psycopg Lambda Layer Builder",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",

"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.13"
}
},

"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-toolsai.jupyter",
"redhat.vscode-yaml",
"ms-vscode.makefile-tools"
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"python.testing.pytestEnabled": true,
"files.exclude": {
"**/build": true,
"**/__pycache__": true,
"**/*.pyc": true
}
}
}
},

"postCreateCommand": "bash .devcontainer/setup.sh && chmod +x scripts/*.sh",

"postStartCommand": "echo 'Psycopg Lambda Layer Builder ready! Layer built and tested successfully.'",

"remoteUser": "root",

"runArgs": [
"--init"
]
}
55 changes: 55 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -e

echo "Setting up Psycopg Lambda Layer Builder environment..."

# Update package lists
apt-get update

# Install software-properties-common for adding PPAs
apt-get install -y software-properties-common

# Add deadsnakes PPA for multiple Python versions
add-apt-repository ppa:deadsnakes/ppa -y

# Update package lists again
apt-get update

# Install build tools (needed for compiling Python packages if any dependencies require it)
echo "Installing build tools..."
apt-get install -y \
gcc g++ make

# Install all Python versions and their development packages
echo "Installing Python versions..."
apt-get install -y \
python3.9 python3.9-dev python3.9-distutils \
python3.10 python3.10-dev python3.10-distutils \
python3.11 python3.11-dev python3.11-distutils \
python3.12 python3.12-dev \
python3.13 python3.13-dev

# Install pip and ensure it's available for all Python versions
echo "Setting up pip for all Python versions..."
apt-get install -y python3-pip python3.9-venv python3.10-venv python3.11-venv python3.12-venv python3.13-venv
python3 -m pip install --upgrade pip

# Install pip for each Python version using get-pip.py
echo "Installing pip for each Python version..."
curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py --ignore-installed --break-system-packages
python3.10 get-pip.py --ignore-installed --break-system-packages
python3.11 get-pip.py --ignore-installed --break-system-packages
python3.12 get-pip.py --ignore-installed --break-system-packages
python3.13 get-pip.py --ignore-installed --break-system-packages
rm get-pip.py

# Make scripts executable
chmod +x scripts/*.sh

# Install psycopg2 for development/testing (optional - not needed for building layers)
echo "Installing psycopg2 for development..."
python3 -m pip install psycopg2-binary --break-system-packages

echo "Environment setup complete!"
echo "To test psycopg2, run: python3 -c 'import psycopg2; print(psycopg2.__version__)'"
96 changes: 96 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Psycopg Lambda Layer CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build and Test Python ${{ matrix.python-version }}
permissions:
contents: read
actions: write
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
gcc g++ make

- name: Build Psycopg layer
run: |
chmod +x scripts/*.sh
./scripts/build.sh

- name: Test Psycopg layer
run: |
./scripts/test.sh

- name: Upload layer artifact
uses: actions/upload-artifact@v4
with:
name: psycopg-layer-python${{ matrix.python-version }}
path: build/psycopg-layer.zip

release:
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
actions: read
id-token: write
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Download layer artifacts
uses: actions/download-artifact@v4
with:
name: psycopg-layer-python${{ matrix.python-version }}
path: layers/

- name: Create Release for Python ${{ matrix.python-version }}
uses: softprops/action-gh-release@v2
with:
tag_name: python${{ matrix.python-version }}-v${{ github.run_number }}
name: Psycopg Layer Python ${{ matrix.python-version }} v${{ github.run_number }}
body: |
## Psycopg Lambda Layer for Python ${{ matrix.python-version }}

This release contains a production-ready Psycopg layer for AWS Lambda with Python ${{ matrix.python-version }}.

### Features
- Psycopg2-binary (latest)
- Python ${{ matrix.python-version }} support
- x86_64 architecture
- Optimized for Lambda runtime
- PostgreSQL database connectivity

### Usage
Upload the `psycopg-layer.zip` file to AWS Lambda as a layer.

### Layer Details
- **Runtime**: Python ${{ matrix.python-version }}
- **Architecture**: x86_64
files: layers/psycopg-layer.zip
draft: false
prerelease: false
11 changes: 11 additions & 0 deletions .github/workflows/commitmsg-conform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Commit Message Conformance
on:
pull_request: {}
permissions:
statuses: write
checks: write
contents: read
pull-requests: read
jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Markdown Lint

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main
25 changes: 25 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"recommendations": [
"ms-python.python",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.isort",
"ms-toolsai.jupyter",
"redhat.vscode-yaml",
"ms-vscode.makefile-tools",
"timonwong.shellcheck",
"ms-vscode.vscode-json",
"github.vscode-pull-request-github",
"ms-vscode.remote-containers",
"ms-vscode.remote-ssh",
"ms-azuretools.vscode-docker",
"hashicorp.terraform",
"ms-vscode.vscode-github-actions",
"github.copilot",
"github.copilot-chat",
"ms-vscode.hexeditor",
"ms-vscode.powershell",
"ms-vscode.vscode-typescript-next"
],
"unwantedRecommendations": ["ms-python.flake8", "ms-python.mypy-type-checker"]
}
35 changes: 35 additions & 0 deletions .vscode/keybindings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.runTask",
"args": "Build Pillow Layer"
},
{
"key": "ctrl+shift+t",
"command": "workbench.action.tasks.runTask",
"args": "Test Pillow Layer"
},
{
"key": "ctrl+shift+m",
"command": "workbench.action.tasks.runTask",
"args": "Build Multi-Version"
},
{
"key": "ctrl+shift+n",
"command": "workbench.action.tasks.runTask",
"args": "Test Multi-Version"
},
{
"key": "ctrl+shift+c",
"command": "workbench.action.tasks.runTask",
"args": "Clean Build"
},
{
"key": "ctrl+shift+f",
"command": "workbench.action.tasks.runTask",
"args": "Format Python"
},
{
"key": "ctrl+shift+l",
"command": "workbench.action.tasks.runTask",
"args": "Lint Python"
}
50 changes: 50 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python: Test Current File",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["${file}", "-v"],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python: Test Psycopg Layer",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/test.sh",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python: Build Psycopg Layer",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/build.sh",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
}
]
}
Loading