Skip to content

Commit 1a6a0cd

Browse files
added test
1 parent 36e579e commit 1a6a0cd

4 files changed

Lines changed: 116 additions & 4 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Integration Test
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
test-action:
16+
name: Test Action End-to-End
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Make test changes
24+
run: |
25+
echo "Integration test run at $(date -u)" > integration-test-output.txt
26+
27+
- name: Run create-pull-request action
28+
id: cpr
29+
uses: ./
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
commit-message: "test: integration test commit"
33+
branch: integration-test/verify-action
34+
title: "test: Verify create-pull-request action works"
35+
body: |
36+
Automated integration test PR.
37+
This PR was created by the integration test workflow to verify the action works correctly.
38+
**This PR can be closed without merging.**
39+
labels: test, automated
40+
delete-branch: true
41+
42+
- name: Verify outputs
43+
run: |
44+
echo "Pull Request Number: ${{ steps.cpr.outputs.pull-request-number }}"
45+
echo "Pull Request URL: ${{ steps.cpr.outputs.pull-request-url }}"
46+
echo "Operation: ${{ steps.cpr.outputs.pull-request-operation }}"
47+
echo "Head SHA: ${{ steps.cpr.outputs.pull-request-head-sha }}"
48+
echo "Branch: ${{ steps.cpr.outputs.pull-request-branch }}"
49+
50+
# Verify critical outputs are non-empty
51+
if [ -z "${{ steps.cpr.outputs.pull-request-number }}" ]; then
52+
echo "FAIL: pull-request-number is empty"
53+
exit 1
54+
fi
55+
56+
if [ -z "${{ steps.cpr.outputs.pull-request-url }}" ]; then
57+
echo "FAIL: pull-request-url is empty"
58+
exit 1
59+
fi
60+
61+
OPERATION="${{ steps.cpr.outputs.pull-request-operation }}"
62+
if [ "$OPERATION" != "created" ] && [ "$OPERATION" != "updated" ]; then
63+
echo "FAIL: unexpected operation '$OPERATION' (expected 'created' or 'updated')"
64+
exit 1
65+
fi
66+
67+
echo "All output validations passed!"
68+
69+
- name: Close test PR
70+
if: steps.cpr.outputs.pull-request-number
71+
run: |
72+
gh pr close ${{ steps.cpr.outputs.pull-request-number }} --delete-branch || true
73+
env:
74+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
test-no-changes:
77+
name: Test No Changes Scenario
78+
runs-on: ubuntu-latest
79+
80+
steps:
81+
- name: Checkout code
82+
uses: actions/checkout@v4
83+
84+
- name: Run action without changes
85+
id: cpr
86+
uses: ./
87+
with:
88+
token: ${{ secrets.GITHUB_TOKEN }}
89+
branch: integration-test/no-changes
90+
91+
- name: Verify no PR was created
92+
run: |
93+
if [ -n "${{ steps.cpr.outputs.pull-request-number }}" ]; then
94+
echo "FAIL: PR was created when no changes exist"
95+
exit 1
96+
fi
97+
echo "Correctly handled no-changes scenario"
98+
99+
test-docker-build:
100+
name: Test Docker Image Runs
101+
runs-on: ubuntu-latest
102+
103+
steps:
104+
- name: Checkout code
105+
uses: actions/checkout@v4
106+
107+
- name: Build Docker image
108+
run: docker build -t cpr-test .
109+
110+
- name: Verify Python module resolves
111+
run: |
112+
docker run --rm --entrypoint python cpr-test -c "from create_pull_request.main import run; print('Module import OK')"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
5858
### Features
5959
- Complete Python port of create-pull-request action
60-
- All 30+ inputs and 4 outputs supported
60+
- All 23 inputs and 6 outputs supported
6161
- Docker-based GitHub Action
6262
- PyGithub for GitHub API interactions
6363
- Comprehensive test coverage

.github/workflows/test.yml

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

33
on:
44
push:
5-
branches: [main, develop]
5+
branches: [master, main, develop]
66
pull_request:
7-
branches: [main]
7+
branches: [master, main]
88

99
jobs:
1010
unit-tests:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN pip install --no-cache-dir -r requirements.txt
2121
COPY src/ ./src/
2222

2323
# Set Python path
24-
ENV PYTHONPATH=/action
24+
ENV PYTHONPATH=/action/src
2525

2626
# Set entrypoint
2727
ENTRYPOINT ["python", "-m", "create_pull_request"]

0 commit comments

Comments
 (0)