Skip to content

Commit b9f8cd9

Browse files
committed
Modernize project structure and CI workflows
Adopt python-repo-template best practices: update Makefile with comprehensive targets, switch to poetry-core, add black and flake8 for code quality, and move tests to the repo root. Overhaul GitHub Actions workflows (CI, Snyk, secrets scan, stale issues), improve dependabot config, and add cursor rules for development standards. Update README, LICENSE, and CHANGELOG to reflect new structure and tooling.
1 parent e604415 commit b9f8cd9

26 files changed

+639
-318
lines changed

.codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ coverage:
22
precision: 2
33
round: down
44
range: 70...100
5-
65
status:
76
project: true
87
patch: false
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
description: General coding standards (language-agnostic)
3+
globs: ["**/*"]
4+
alwaysApply: true
5+
---
6+
7+
# General Coding Standards
8+
9+
## Documentation & Instructions
10+
11+
- **Be concise** - Instructions, rules, and documentation should be brief and actionable
12+
- **Focus on essentials** - Include only what's necessary, remove verbose explanations
13+
14+
## File Formatting
15+
16+
- **End files with newline** - POSIX standard, required for Git diffs
17+
- **Use LF (`\n`) line endings** - Not CRLF (`\r\n`), except `.bat`/`.cmd` files
18+
- **No trailing whitespace** - Remove spaces/tabs at end of lines
19+
- **Consistent indentation** - Spaces or tabs, never mixed
20+
21+
## File Naming
22+
23+
- **Lowercase with hyphens** - `my-file.txt` not `My-File.txt`
24+
- **Be descriptive** - `user-authentication.py` not `auth.py`
25+
- **Avoid special characters** - Use only `a-z`, `0-9`, `-`, `_`, `.`
26+
27+
**Exceptions:**
28+
- Python: `snake_case.py`
29+
- JavaScript/TypeScript: `PascalCase.tsx`
30+
31+
## Git
32+
33+
**Commits:**
34+
- Atomic (one change per commit)
35+
- Present tense messages ("Add feature" not "Added feature")
36+
- Include issue numbers (`Fixes #123`)
37+
38+
**Never commit:**
39+
- ❌ Build artifacts (`dist/`, `build/`)
40+
- ❌ Dependencies (`node_modules/`, `.venv/`)
41+
- ❌ IDE files (`.vscode/`, `.idea/`)
42+
- ❌ OS files (`.DS_Store`, `Thumbs.db`)
43+
- ❌ Secrets or credentials
44+
45+
## Security
46+
47+
- **Never commit secrets** - Use environment variables
48+
- **Pin dependency versions** - Use exact versions
49+
- **Use secret scanners** - gitleaks, truffleHog
50+
- **Security scanning** - Snyk, Dependabot
51+
52+
## Before Committing
53+
54+
- [ ] Tests pass
55+
- [ ] No linter errors
56+
- [ ] No trailing whitespace
57+
- [ ] Newline at end of files
58+
- [ ] No debug code
59+
- [ ] Documentation updated

.cursor/rules/makefile-python.mdc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
description: Makefile-based development workflow for Python projects using Poetry
3+
globs: ["Makefile", "pyproject.toml", "**/*.py"]
4+
alwaysApply: true
5+
---
6+
7+
# Python Project Development Workflow
8+
9+
## Available Makefile Targets
10+
11+
### Setup
12+
- `make setup-init` - Complete first-time setup (configure venv, lock, install all deps)
13+
- `make setup-venv` - Configure Poetry to use .venv in project directory
14+
15+
### Installation
16+
- `make install` - Install main dependencies only
17+
- `make install-dev` - Install main + dev dependencies
18+
- `make install-test` - Install main + test dependencies
19+
- `make install-all` - Install all dependencies (main + dev + test)
20+
21+
### Dependency Management
22+
- `make lock` - Regenerate poetry.lock from pyproject.toml
23+
- `make update-deps` - Update dependencies to latest compatible versions
24+
25+
### Testing
26+
- `make test` - Run unit tests without coverage
27+
- `make test-with-coverage` - Run unit tests with coverage reporting
28+
29+
### Code Quality
30+
- `make lint-python` - Lint Python code with flake8
31+
- `make lint-yaml` - Lint YAML files with yamllint
32+
- `make format-python` - Format Python code with black
33+
- `make pre-commit` - Run all quality checks (format, lint, test)
34+
35+
### Build
36+
- `make build` - Build the Python package
37+
38+
### Cleanup
39+
- `make clean` - Clean test artifacts, build artifacts and temporary files
40+
- `make clean-all` - Clean everything including virtual environment
41+
42+
### Help
43+
- `make help` - Show all available targets
44+
45+
## Project Setup
46+
47+
**Quick Start:**
48+
```bash
49+
make setup-init # Complete first-time setup
50+
make test-with-coverage # Verify installation
51+
```
52+
53+
## Python Environment
54+
- **Poetry** - Dependency management
55+
- **Python 3.10+** - Minimum version (supports 3.10, 3.11, 3.12, 3.13)
56+
- **`.venv/`** - Virtual environment (project-local)
57+
- **Dependencies** in `pyproject.toml`:
58+
- Main: boto3, click, InquirerPy
59+
- Test: pytest, pytest-cov, pytest-mock, coverage, mock
60+
- Dev: black, flake8, yamllint
61+
62+
## Development Workflow
63+
64+
**Daily development:**
65+
```bash
66+
# 1. Make code changes
67+
# 2. Run all quality checks before committing
68+
make pre-commit # Format, lint, and test everything
69+
# Or run individual checks:
70+
make format-python # Auto-format
71+
make lint-python # Lint Python
72+
make lint-yaml # Lint YAML
73+
make test-with-coverage # Test with coverage
74+
make clean # Remove artifacts
75+
```
76+
77+
## Project Structure
78+
- Main package: `saml2awsmulti/`
79+
- Tests: `tests/`
80+
- CLI entry point: `awslogin` (defined in pyproject.toml)
81+
- Configuration: `pyproject.toml`
82+
83+
## CLI Tool Usage
84+
After installation with `pip install .` or `pipx install .`:
85+
```bash
86+
awslogin # Main CLI tool
87+
awslogin --help # Show help
88+
awslogin switch # Switch AWS profile
89+
awslogin whoami # Show current identity
90+
```

.cursor/rules/makefile-workflow.mdc

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

.github/dependabot.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
version: 2
22
updates:
3+
# GitHub Actions dependencies
34
- package-ecosystem: github-actions
45
directory: "/"
56
groups:
@@ -11,18 +12,7 @@ updates:
1112
time: "08:00"
1213
timezone: Australia/Melbourne
1314

14-
- package-ecosystem: pip
15-
directory: "/"
16-
groups:
17-
all-dependencies:
18-
patterns:
19-
- "*"
20-
schedule:
21-
interval: weekly
22-
time: "09:00"
23-
timezone: Australia/Melbourne
24-
open-pull-requests-limit: 1
25-
15+
# Python dependencies managed by Poetry
2616
- package-ecosystem: poetry
2717
directory: "/"
2818
groups:
@@ -31,6 +21,6 @@ updates:
3121
- "*"
3222
schedule:
3323
interval: weekly
34-
time: "09:30"
24+
time: "08:00"
3525
timezone: Australia/Melbourne
3626
open-pull-requests-limit: 1
Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,64 @@
1-
name: Build and Test
1+
name: CI
2+
run-name: CI @ ${{ github.ref_name }}
23

34
on:
45
push:
5-
paths-ignore:
6-
- '**.json'
7-
- '**.md'
6+
branches: [main, master]
7+
paths:
8+
- .github/**
9+
- saml2awsmulti/**
10+
- Makefile
11+
- poetry.lock
12+
- pyproject.toml
13+
pull_request:
14+
branches: [main, master]
15+
paths:
16+
- .github/**
17+
- saml2awsmulti/**
18+
- Makefile
19+
- poetry.lock
20+
- pyproject.toml
21+
workflow_dispatch:
22+
23+
concurrency:
24+
group: ${{ github.workflow }}
25+
cancel-in-progress: false
826

927
defaults:
1028
run:
1129
shell: bash
1230

1331
jobs:
1432
lint:
15-
name: Run yamllint on workflows
33+
name: Lint code
1634
runs-on: ubuntu-latest
1735
steps:
1836
- uses: actions/checkout@v5
37+
1938
- name: Set up Python
2039
uses: actions/setup-python@v6
2140
with:
2241
python-version: "3.13"
42+
2343
- name: Install Poetry
24-
run: pip install poetry
25-
- name: Install yamllint
26-
run: poetry install --only dev
27-
- name: Run yamllint
28-
run: make yamllint
44+
uses: snok/install-poetry@v1
45+
with:
46+
version: latest
47+
virtualenvs-create: true
48+
virtualenvs-in-project: true
49+
50+
- name: Lint YAML
51+
run: make lint-yaml
52+
53+
- name: Lint Python
54+
run: make lint-python
2955

30-
build:
56+
test:
3157
needs: lint
3258
runs-on: ubuntu-latest
3359
strategy:
3460
matrix:
35-
python-version: ["3.11", "3.12", "3.13"]
61+
python-version: ["3.10", "3.11", "3.12", "3.13"]
3662

3763
steps:
3864
- name: Checkout source
@@ -44,10 +70,10 @@ jobs:
4470
python-version: ${{ matrix.python-version }}
4571

4672
- name: Install dependencies
47-
run: make install-test-deps
73+
run: make install-test
4874

4975
- name: Run tests with coverage
50-
run: make test-coverage
76+
run: make test-with-coverage
5177

5278
- name: Upload coverage to Codecov
5379
if: matrix.python-version == '3.13'

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CodeQL
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, master]
66
schedule:
77
- cron: '0 19 * * 5'
88

.github/workflows/dependabot-auto-approve-merge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Dependabot auto-approve auto-merge
2+
23
on: pull_request
34

45
permissions:

.github/workflows/secrets-scan.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Secrets Scan
22

33
on: [push, workflow_dispatch]
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
59
jobs:
610
Gitleaks:
711
name: Gitleaks Secrets Scan

.github/workflows/snyk.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Snyk Checks
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
security:
18+
name: Run Snyk to check for vulnerabilities
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout sources
22+
uses: actions/checkout@v5
23+
24+
- name: Run Snyk to check for vulnerabilities
25+
uses: snyk/actions/python@master
26+
continue-on-error: true # To make sure that SARIF upload gets called
27+
env:
28+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
29+
with:
30+
args: --all-projects --severity-threshold=high --sarif-file-output=snyk.sarif
31+
32+
- name: Upload result to GitHub Code Scanning
33+
uses: github/codeql-action/upload-sarif@v4
34+
with:
35+
sarif_file: snyk.sarif

0 commit comments

Comments
 (0)