Skip to content

Commit 373a736

Browse files
committed
Merge branch 'main' into feat/json-logger
2 parents b95fc8a + a63ed9e commit 373a736

29 files changed

+997
-149
lines changed

.docker/minio/setup.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# Simple script to set up MinIO bucket and user
4+
# Based on example from MinIO issues
5+
6+
# Format bucket name to ensure compatibility
7+
BUCKET_NAME=$(echo "${S3_BUCKET_NAME}" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
8+
9+
# Configure MinIO client
10+
mc alias set myminio http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
11+
12+
# Remove bucket if it exists (for clean setup)
13+
mc rm -r --force myminio/${BUCKET_NAME} || true
14+
15+
# Create bucket
16+
mc mb myminio/${BUCKET_NAME}
17+
18+
# Set bucket policy to allow downloads
19+
mc anonymous set download myminio/${BUCKET_NAME}
20+
21+
# Create user with access and secret keys
22+
mc admin user add myminio ${S3_ACCESS_KEY} ${S3_SECRET_KEY} || echo "User already exists"
23+
24+
# Create policy for the bucket
25+
echo '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:*"],"Resource":["arn:aws:s3:::'${BUCKET_NAME}'/*","arn:aws:s3:::'${BUCKET_NAME}'"]}]}' > /tmp/policy.json
26+
27+
# Apply policy
28+
mc admin policy create myminio gitingest-policy /tmp/policy.json || echo "Policy already exists"
29+
mc admin policy attach myminio gitingest-policy --user ${S3_ACCESS_KEY}
30+
31+
echo "MinIO setup completed successfully"
32+
echo "Bucket: ${BUCKET_NAME}"
33+
echo "Access via console: http://localhost:9001"

.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,27 @@ GITINGEST_SENTRY_SEND_DEFAULT_PII=true
3434
# Environment name for Sentry (default: "")
3535
GITINGEST_SENTRY_ENVIRONMENT=development
3636

37+
# MinIO Configuration (for development)
38+
# Root user credentials for MinIO admin access
39+
MINIO_ROOT_USER=minioadmin
40+
MINIO_ROOT_PASSWORD=minioadmin
41+
42+
# S3 Configuration (for application)
43+
# Set to "true" to enable S3 storage for digests
44+
# S3_ENABLED=true
45+
# Endpoint URL for the S3 service (MinIO in development)
46+
S3_ENDPOINT=http://minio:9000
47+
# Access key for the S3 bucket (created automatically in development)
48+
S3_ACCESS_KEY=gitingest
49+
# Secret key for the S3 bucket (created automatically in development)
50+
S3_SECRET_KEY=gitingest123
51+
# Name of the S3 bucket (created automatically in development)
52+
S3_BUCKET_NAME=gitingest-bucket
53+
# Region for the S3 bucket (default for MinIO)
54+
S3_REGION=us-east-1
55+
# Public URL/CDN for accessing S3 resources
56+
S3_ALIAS_HOST=127.0.0.1:9000/gitingest-bucket
57+
# Optional prefix for S3 file paths (if set, prefixes all S3 paths with this value)
58+
# S3_DIRECTORY_PREFIX=my-prefix
59+
3760
LOG_FORMAT=JSON

.github/workflows/ci.yml

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
812

913
permissions:
1014
contents: read
@@ -17,67 +21,63 @@ jobs:
1721
matrix:
1822
os: [ubuntu-latest, macos-latest, windows-latest]
1923
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
20-
2124
include:
2225
- os: ubuntu-latest
2326
python-version: "3.13"
2427
coverage: true
2528

2629
steps:
27-
- name: Harden the runner (Audit all outbound calls)
28-
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
29-
with:
30-
egress-policy: audit
31-
32-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
- name: Harden the runner (Audit all outbound calls)
31+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
32+
with:
33+
egress-policy: audit
3334

34-
- name: Set up Python
35-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
36-
with:
37-
python-version: ${{ matrix.python-version }}
35+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3836

39-
- name: Locate pip cache
40-
id: pip-cache
41-
shell: bash
42-
run: echo "dir=$(python -m pip cache dir)" >> "$GITHUB_OUTPUT"
37+
- name: Set up Python
38+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
cache: 'pip'
4342

44-
- name: Cache pip
45-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
46-
with:
47-
path: ${{ steps.pip-cache.outputs.dir }}
48-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
49-
restore-keys: ${{ runner.os }}-pip-
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
python -m pip install ".[dev,server]"
5047
51-
- name: Install dependencies
52-
run: |
53-
python -m pip install --upgrade pip
54-
python -m pip install ".[dev,server]"
48+
- name: Cache pytest results
49+
uses: actions/cache@v4
50+
with:
51+
path: .pytest_cache
52+
key: ${{ runner.os }}-pytest-${{ matrix.python-version }}-${{ hashFiles('**/pytest.ini') }}
53+
restore-keys: |
54+
${{ runner.os }}-pytest-${{ matrix.python-version }}-
5555
56-
- name: Run tests
57-
if: ${{ matrix.coverage != true }}
58-
run: pytest
56+
- name: Run tests
57+
if: ${{ matrix.coverage != true }}
58+
run: pytest
5959

60-
- name: Run tests and collect coverage
61-
if: ${{ matrix.coverage == true }}
62-
run: |
63-
pytest \
64-
--cov=gitingest \
65-
--cov=server \
66-
--cov-branch \
67-
--cov-report=xml \
68-
--cov-report=term
60+
- name: Run tests and collect coverage
61+
if: ${{ matrix.coverage == true }}
62+
run: |
63+
pytest \
64+
--cov=gitingest \
65+
--cov=server \
66+
--cov-branch \
67+
--cov-report=xml \
68+
--cov-report=term
6969
70-
- name: Upload coverage to Codecov
71-
if: ${{ matrix.coverage == true }}
72-
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
73-
with:
74-
token: ${{ secrets.CODECOV_TOKEN }}
75-
files: coverage.xml
76-
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
77-
name: codecov-${{ matrix.os }}-${{ matrix.python-version }}
78-
fail_ci_if_error: true
79-
verbose: true
70+
- name: Upload coverage to Codecov
71+
if: ${{ matrix.coverage == true }}
72+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
73+
with:
74+
token: ${{ secrets.CODECOV_TOKEN }}
75+
files: coverage.xml
76+
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
77+
name: codecov-${{ matrix.os }}-${{ matrix.python-version }}
78+
fail_ci_if_error: true
79+
verbose: true
8080

81-
- name: Run pre-commit hooks
82-
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
83-
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}
81+
- name: Run pre-commit hooks
82+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
83+
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build & Push Container
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
tags:
8+
- '*'
9+
merge_group:
10+
pull_request:
11+
types: [labeled, synchronize, reopened, ready_for_review, opened]
12+
13+
env:
14+
PUSH_FROM_PR: >-
15+
${{ github.event_name == 'pull_request' &&
16+
(
17+
contains(github.event.pull_request.labels.*.name, 'push-container') ||
18+
contains(github.event.pull_request.labels.*.name, 'deploy-pr-temp-env')
19+
)
20+
}}
21+
22+
jobs:
23+
terraform:
24+
name: "ECR"
25+
runs-on: ubuntu-latest
26+
if: github.repository == 'coderamp-labs/gitingest'
27+
28+
permissions:
29+
id-token: write
30+
contents: read
31+
pull-requests: write
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: configure aws credentials
38+
uses: aws-actions/configure-aws-credentials@v4
39+
with:
40+
role-to-assume: ${{ secrets.CODERAMP_AWS_ECR_REGISTRY_PUSH_ROLE_ARN }}
41+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
42+
aws-region: eu-west-1
43+
44+
- name: Set current timestamp
45+
id: vars
46+
run: |
47+
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
48+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
49+
50+
- name: Login to Amazon ECR
51+
id: login-ecr
52+
uses: aws-actions/amazon-ecr-login@v2
53+
54+
- name: Docker Meta
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: |
59+
${{ secrets.ECR_REGISTRY_URL }}
60+
flavor: |
61+
latest=false
62+
tags: |
63+
type=ref,event=branch,branch=main,suffix=-${{ steps.vars.outputs.sha_short }}-${{ steps.vars.outputs.timestamp }}
64+
type=ref,event=pr,suffix=-${{ steps.vars.outputs.sha_short }}-${{ steps.vars.outputs.timestamp }}
65+
type=pep440,pattern={{raw}}
66+
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@v3
69+
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
73+
- name: Build and push
74+
uses: docker/build-push-action@v6
75+
with:
76+
context: .
77+
platforms: linux/amd64, linux/arm64
78+
push: ${{ github.event_name != 'pull_request' || env.PUSH_FROM_PR == 'true' }}
79+
tags: ${{ steps.meta.outputs.tags }}
80+
labels: ${{ steps.meta.outputs.labels }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ concurrency:
1717
env:
1818
REGISTRY: ghcr.io
1919
IMAGE_NAME: ${{ github.repository }}
20-
# Now allow pushing from PRs when either 'push-container' OR 'deploy-pr-temp-env' is present:
2120
PUSH_FROM_PR: >-
2221
${{ github.event_name == 'pull_request' &&
2322
(
@@ -31,6 +30,7 @@ permissions:
3130

3231
jobs:
3332
docker-build:
33+
name: "GHCR"
3434
runs-on: ubuntu-latest
3535
permissions:
3636
contents: read

.github/workflows/publish_to_pypi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
run: |
3232
python -m pip install --upgrade pip
3333
python -m pip install build twine
34+
python -m build
3435
twine check dist/*
3536
- name: Upload dist artefact
3637
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PR Needs Rebase
2+
3+
on:
4+
workflow_dispatch: {}
5+
schedule:
6+
- cron: '0 * * * *'
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
label-rebase-needed:
13+
runs-on: ubuntu-latest
14+
if: github.repository == 'coderamp-labs/gitingest'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
steps:
21+
- name: Check for merge conflicts
22+
uses: eps1lon/actions-label-merge-conflict@v3
23+
with:
24+
dirtyLabel: 'rebase needed :construction:'
25+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
26+
commentOnClean: This pull request has resolved merge conflicts and is ready for review.
27+
commentOnDirty: This pull request has merge conflicts that must be resolved before it can be merged.
28+
retryMax: 30
29+
continueOnMissingPermissions: false

.github/workflows/stale.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Close stale issues and PRs"
2+
3+
on:
4+
schedule:
5+
- cron: "0 6 * * *"
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
12+
jobs:
13+
stale:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/stale@v9
17+
with:
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
days-before-stale: 45
20+
days-before-close: 10
21+
stale-issue-label: stale
22+
stale-pr-label: stale
23+
stale-issue-message: |
24+
Hi there! We haven’t seen activity here for 45 days, so I’m marking this issue as stale.
25+
If you’d like to keep it open, please leave a comment within 10 days. Thanks!
26+
stale-pr-message: |
27+
Hi there! We haven’t seen activity on this pull request for 45 days, so I’m marking it as stale.
28+
If you’d like to keep it open, please leave a comment within 10 days. Thanks!
29+
close-issue-message: |
30+
Hi there! We haven’t heard anything for 10 days, so I’m closing this issue. Feel free to reopen if you’d like to continue the discussion. Thanks!
31+
close-pr-message: |
32+
Hi there! We haven’t heard anything for 10 days, so I’m closing this pull request. Feel free to reopen if you’d like to continue working on it. Thanks!

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ repos:
8989
hooks:
9090
- id: markdownlint
9191
description: 'Lint markdown files.'
92-
args: ['--disable=line-length']
92+
args: ['--disable=line-length', '--ignore=CHANGELOG.md']
9393

9494
- repo: https://github.com/astral-sh/ruff-pre-commit
9595
rev: v0.12.2
@@ -113,6 +113,7 @@ repos:
113113
files: ^src/
114114
additional_dependencies:
115115
[
116+
boto3>=1.28.0,
116117
click>=8.0.0,
117118
'fastapi[standard]>=0.109.1',
118119
httpx,
@@ -139,6 +140,7 @@ repos:
139140
- --rcfile=tests/.pylintrc
140141
additional_dependencies:
141142
[
143+
boto3>=1.28.0,
142144
click>=8.0.0,
143145
'fastapi[standard]>=0.109.1',
144146
httpx,

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{".":"0.1.5"}
1+
{".":"0.2.1"}

0 commit comments

Comments
 (0)