Repository navigation
Expand file tree
/
Copy pathtest.core.action.commit_operations.yml
More file actions
171 lines (149 loc) · 5.04 KB
/
Copy pathtest.core.action.commit_operations.yml
File metadata and controls
171 lines (149 loc) · 5.04 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Test Core Commit Operations
on:
push:
branches: [main, staging, develop/*, feature/*]
paths:
- 'actions/core/commit_operations/**'
- '.github/workflows/test.core.action.commit_operations.yml'
tags-ignore:
- '**'
pull_request:
paths:
- 'actions/core/commit_operations/**'
- '.github/workflows/test.core.action.commit_operations.yml'
workflow_dispatch:
inputs:
debug:
description: 'Enable debug logging'
required: false
default: 'false'
jobs:
test-unit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.9'
- name: Install test dependencies
run: |
cd actions/core/commit_operations
pip install pytest pytest-cov
- name: Run unit tests
run: |
cd actions/core/commit_operations
python -m pytest tests/test_unit.py -v --cov=main --cov-report=term
- name: Check code coverage
run: |
cd actions/core/commit_operations
python -m pytest tests/test_unit.py --cov=main --cov-fail-under=80
test-action:
runs-on: ubuntu-latest
needs: [test-unit]
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup test environment
run: |
git config --global user.email "test@github.com"
git config --global user.name "Test User"
git config --global --add safe.directory $GITHUB_WORKSPACE
# Initialize a clean environment
git checkout -b test-commits || true
# Create a test file
echo "Test content" > test.txt
git add test.txt
git commit -m "Initial commit"
# Create a change to commit
- name: Create test file change
run: |
# Create a new test file
echo "# Test feature" > feature.md
git add feature.md
# Test create commit action
- name: Test create commit
id: create-commit
uses: ./actions/core/commit_operations
with:
action: create
message: "Add new feature"
# Verify outputs
- name: Verify commit was created
run: |
if [[ "${{ steps.create-commit.outputs.result }}" != "success" ]]; then
echo "Commit creation failed"
exit 1
fi
if [[ -z "${{ steps.create-commit.outputs.commit_hash }}" ]]; then
echo "No commit hash returned"
exit 1
fi
# Verify the commit exists
if ! git show ${{ steps.create-commit.outputs.commit_hash }} | grep -q "Add new feature"; then
echo "Cannot find commit with expected message"
exit 1
fi
# Fix permissions after Docker action
- name: Fix file permissions
run: |
# Docker actions may create files with different ownership
# Fix permissions to allow subsequent operations
sudo chown -R $USER:$USER .
# Create another change for amending
- name: Create change for amend
run: |
# Modify the feature file
echo "# Additional content" >> feature.md
git add feature.md
# Test amend commit action
- name: Test amend commit
id: amend-commit
uses: ./actions/core/commit_operations
with:
action: amend
message: "Add new feature with improvements"
# Verify amend commit
- name: Verify amended commit
run: |
if [[ "${{ steps.amend-commit.outputs.result }}" != "success" ]]; then
echo "Amend commit failed"
exit 1
fi
if [[ -z "${{ steps.amend-commit.outputs.commit_hash }}" ]]; then
echo "No commit hash returned from amend"
exit 1
fi
# Test list commits action
- name: Test list commits
id: list-commits
uses: ./actions/core/commit_operations
with:
action: list
limit: 5
# Verify list output
- name: Verify commit list
run: |
if [[ "${{ steps.list-commits.outputs.result }}" != "success" ]]; then
echo "List commits failed"
exit 1
fi
if [[ -z "${{ steps.list-commits.outputs.commits }}" ]]; then
echo "No commits returned"
exit 1
fi
# Test get commit info
- name: Test get commit info
id: get-commit
uses: ./actions/core/commit_operations
with:
action: get
commit_hash: ${{ steps.amend-commit.outputs.commit_hash }}
# Test revert commit
- name: Test revert commit
id: revert-commit
uses: ./actions/core/commit_operations
with:
action: revert
commit_hash: ${{ steps.amend-commit.outputs.commit_hash }}