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