Skip to content

Commit e7f6600

Browse files
add the change
0 parents  commit e7f6600

28 files changed

Lines changed: 5036 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
build-and-release:
14+
name: Build and Release
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract version from tag
32+
id: version
33+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
push: true
40+
tags: |
41+
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
42+
ghcr.io/${{ github.repository }}:latest
43+
cache-from: type=gha
44+
cache-to: type=gha,mode=max
45+
46+
- name: Create GitHub Release
47+
uses: actions/create-release@v1
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
tag_name: ${{ github.ref }}
52+
release_name: Release ${{ steps.version.outputs.VERSION }}
53+
body: |
54+
## Create Pull Request Action - Python Port
55+
56+
Release ${{ steps.version.outputs.VERSION }}
57+
58+
### Features
59+
- Complete Python port of create-pull-request action
60+
- All 30+ inputs and 4 outputs supported
61+
- Docker-based GitHub Action
62+
- PyGithub for GitHub API interactions
63+
- Comprehensive test coverage
64+
65+
### Usage
66+
```yaml
67+
- name: Create Pull Request
68+
uses: ${{ github.repository }}@${{ steps.version.outputs.VERSION }}
69+
with:
70+
token: ${{ secrets.GITHUB_TOKEN }}
71+
commit-message: "Update files"
72+
branch: feature-branch
73+
title: "Automated PR"
74+
```
75+
76+
### Docker Image
77+
```
78+
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
79+
```
80+
81+
See [README.md](https://github.com/${{ github.repository }}/blob/${{ steps.version.outputs.VERSION }}/README.md) for full documentation.
82+
draft: false
83+
prerelease: false
84+
85+
update-major-tag:
86+
name: Update Major Version Tag
87+
runs-on: ubuntu-latest
88+
needs: build-and-release
89+
90+
steps:
91+
- name: Checkout code
92+
uses: actions/checkout@v4
93+
94+
- name: Extract major version
95+
id: major
96+
run: |
97+
TAG=${GITHUB_REF#refs/tags/}
98+
MAJOR=$(echo $TAG | cut -d. -f1)
99+
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
100+
101+
- name: Update major version tag
102+
run: |
103+
git config user.name github-actions
104+
git config user.email github-actions@github.com
105+
git tag -fa ${{ steps.major.outputs.MAJOR }} -m "Update ${{ steps.major.outputs.MAJOR }} tag"
106+
git push origin ${{ steps.major.outputs.MAJOR }} --force

.github/workflows/test.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.9', '3.10', '3.11']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
pip install pytest pytest-cov pytest-mock
31+
32+
- name: Run unit tests
33+
run: |
34+
PYTHONPATH=src pytest tests/unit/ -v --cov=src/create_pull_request --cov-report=xml --cov-report=term
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v4
38+
if: matrix.python-version == '3.11'
39+
with:
40+
file: ./coverage.xml
41+
flags: unittests
42+
name: codecov-umbrella
43+
44+
integration-tests:
45+
name: Integration Tests
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.11'
56+
57+
- name: Install dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install -r requirements.txt
61+
pip install pytest pytest-mock
62+
63+
- name: Configure git
64+
run: |
65+
git config --global user.name "GitHub Actions"
66+
git config --global user.email "actions@github.com"
67+
68+
- name: Run integration tests
69+
run: |
70+
PYTHONPATH=src pytest tests/integration/ -v
71+
72+
docker-build:
73+
name: Docker Build
74+
runs-on: ubuntu-latest
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@v3
82+
83+
- name: Build Docker image
84+
run: |
85+
docker build -t create-pull-request-python:test .
86+
87+
- name: Test Docker image
88+
run: |
89+
docker run --rm create-pull-request-python:test --help || true
90+
91+
- name: Check image size
92+
run: |
93+
docker images create-pull-request-python:test --format "{{.Size}}"
94+
95+
lint:
96+
name: Lint and Type Check
97+
runs-on: ubuntu-latest
98+
99+
steps:
100+
- name: Checkout code
101+
uses: actions/checkout@v4
102+
103+
- name: Set up Python
104+
uses: actions/setup-python@v5
105+
with:
106+
python-version: '3.11'
107+
108+
- name: Install dependencies
109+
run: |
110+
python -m pip install --upgrade pip
111+
pip install ruff mypy
112+
113+
- name: Run ruff
114+
run: |
115+
ruff check src/
116+
117+
- name: Run mypy
118+
run: |
119+
mypy src/create_pull_request --ignore-missing-imports || true
120+
121+
all-checks:
122+
name: All Checks Passed
123+
runs-on: ubuntu-latest
124+
needs: [unit-tests, integration-tests, docker-build, lint]
125+
steps:
126+
- name: Success
127+
run: echo "All checks passed!"

.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual environments
24+
venv/
25+
env/
26+
ENV/
27+
.venv
28+
29+
# Testing
30+
.pytest_cache/
31+
.coverage
32+
coverage.xml
33+
htmlcov/
34+
.tox/
35+
36+
# IDEs
37+
.vscode/
38+
.idea/
39+
*.swp
40+
*.swo
41+
*~
42+
43+
# OS
44+
.DS_Store
45+
Thumbs.db
46+
47+
# Logs
48+
*.log
49+
50+
# Temporary files
51+
*.tmp
52+
.temp/

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM python:3.11-slim
2+
3+
LABEL maintainer="Create Pull Request Action"
4+
LABEL description="Creates a pull request for changes to your repository in the actions workspace"
5+
LABEL version="1.0.0"
6+
7+
# Install git
8+
RUN apt-get update && \
9+
apt-get install -y git && \
10+
apt-get clean && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
# Set working directory
14+
WORKDIR /action
15+
16+
# Copy requirements and install dependencies
17+
COPY requirements.txt .
18+
RUN pip install --no-cache-dir -r requirements.txt
19+
20+
# Copy source code
21+
COPY src/ ./src/
22+
23+
# Set Python path
24+
ENV PYTHONPATH=/action
25+
26+
# Set entrypoint
27+
ENTRYPOINT ["python", "-m", "create_pull_request"]

0 commit comments

Comments
 (0)