@@ -11,18 +11,16 @@ permissions:
1111 contents : write
1212
1313jobs :
14- test_scans :
15- name : Test local file, artifact, and release asset scanning
16- runs-on : ubuntu-latest
14+ local_file_scan :
15+ name : Test local file (<10MB)
16+ runs-on : ubuntu-slim
1717 steps :
18- # Checkout the repository to access files
1918 - name : Checkout
2019 uses : actions/checkout@v6
2120
22- # Test 1: Scan local file
2321 - name : Scan local .gitignore file
2422 id : scan_local
25- uses : ./ # Uses the action in the root directory
23+ uses : ./
2624 with :
2725 local-file-path : .gitignore
2826 api-key : ${{ secrets.ATTACHMENTAV_API_KEY }}
3735 echo "Finding: ${{ steps.scan_local.outputs.finding }}"
3836 fi
3937
40- # Test 2: Create and scan artifact
38+ artifact_scan :
39+ name : Test artifact
40+ runs-on : ubuntu-slim
41+ steps :
42+ - name : Checkout
43+ uses : actions/checkout@v6
44+
4145 - name : Upload action.yml as artifact
4246 id : upload_artifact
4347 uses : actions/upload-artifact@v6
6367 echo "Finding: ${{ steps.scan_artifact.outputs.finding }}"
6468 fi
6569
66- # Test 3: Create release and scan asset
70+ release_scan :
71+ name : Test release
72+ runs-on : ubuntu-slim
73+ steps :
74+ - name : Checkout
75+ uses : actions/checkout@v6
76+
6777 - name : Create release with action.yml asset
6878 id : create_release
6979 run : |
@@ -102,15 +112,46 @@ jobs:
102112 echo "Finding: ${{ steps.scan_asset.outputs.finding }}"
103113 fi
104114
105- # Test 4: Scan local file >10MB
115+ - name : Cleanup test release
116+ if : always() && steps.create_release.outcome == 'success'
117+ run : |
118+ if [ -n "${{ steps.create_release.outputs.tag_name }}" ]; then
119+ gh release delete "${{ steps.create_release.outputs.tag_name }}" --yes --cleanup-tag || true
120+ fi
121+ env :
122+ GH_TOKEN : ${{ github.token }}
123+
124+ local_file_scan_large :
125+ name : Test large local file (80MB)
126+ runs-on : ubuntu-slim
127+ steps :
128+ - name : Checkout
129+ uses : actions/checkout@v6
130+
106131 - name : Generate 80MB local file
107132 run : |
108133 mkdir test-data
109134 head -c 83886080 </dev/urandom >test-data/random-80mb-file
110135
136+ - name : Create temporary branch and commit file
137+ id : create_temp_branch
138+ run : |
139+ BRANCH_NAME="ci-tests-${{ github.run_number }}-${{ github.run_attempt }}"
140+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
141+
142+ git config user.name "github-actions[bot]"
143+ git config user.email "github-actions[bot]@users.noreply.github.com"
144+ git checkout -b "$BRANCH_NAME"
145+ git add test-data/random-80mb-file
146+ git commit -m "Add 80MB test file for CI"
147+ git push origin "$BRANCH_NAME"
148+ echo "Temporary branch created: $BRANCH_NAME"
149+
111150 - name : Scan local random-80mb-file
112151 id : scan_local_80mb
113- uses : ./ # Uses the action in the root directory
152+ uses : ./
153+ env :
154+ GIT_REF : ${{ steps.create_temp_branch.outputs.branch_name }}
114155 with :
115156 local-file-path : test-data/random-80mb-file
116157 api-key : ${{ secrets.ATTACHMENTAV_API_KEY }}
@@ -126,9 +167,24 @@ jobs:
126167 echo "Finding: ${{ steps.scan_local_80mb.outputs.finding }}"
127168 fi
128169
129- # Test 5: Create and scan >200MB artifact
130- - name : Duplicate test-data
170+ - name : Cleanup temporary branch
171+ if : always() && steps.create_temp_branch.outcome == 'success'
131172 run : |
173+ if [ -n "${{ steps.create_temp_branch.outputs.branch_name }}" ]; then
174+ git push origin --delete "${{ steps.create_temp_branch.outputs.branch_name }}" || true
175+ fi
176+
177+ artifact_scan_large :
178+ name : Test large artifact (>200MB)
179+ runs-on : ubuntu-slim
180+ steps :
181+ - name : Checkout
182+ uses : actions/checkout@v6
183+
184+ - name : Create large test data
185+ run : |
186+ mkdir test-data
187+ head -c 83886080 </dev/urandom >test-data/random-80mb-file
132188 cp test-data/random-80mb-file test-data/random-80mb-file2
133189 cp test-data/random-80mb-file test-data/random-80mb-file3
134190 cp test-data/random-80mb-file test-data/random-80mb-file4
@@ -159,7 +215,33 @@ jobs:
159215 echo "Finding: ${{ steps.scan_artifact_large.outputs.finding }}"
160216 fi
161217
162- # Test 6: Create release with large asset and scan asset
218+ - name : Cleanup large artifact file
219+ if : always() && steps.upload_artifact_large.outcome == 'success'
220+ run : |
221+ if [ -n "${{ steps.upload_artifact_large.outputs.artifact-id }}" ]; then
222+ curl -L \
223+ -X DELETE \
224+ -H "Accept: application/vnd.github+json" \
225+ -H "Authorization: Bearer ${{ github.token }}" \
226+ -H "X-GitHub-Api-Version: 2022-11-28" \
227+ https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ steps.upload_artifact_large.outputs.artifact-id }}
228+ fi
229+
230+ release_scan_large :
231+ name : Test large release (>200MB)
232+ runs-on : ubuntu-slim
233+ steps :
234+ - name : Checkout
235+ uses : actions/checkout@v6
236+
237+ - name : Create large test data
238+ run : |
239+ mkdir test-data
240+ head -c 83886080 </dev/urandom >test-data/random-80mb-file
241+ cp test-data/random-80mb-file test-data/random-80mb-file2
242+ cp test-data/random-80mb-file test-data/random-80mb-file3
243+ cp test-data/random-80mb-file test-data/random-80mb-file4
244+
163245 - name : Create release with test-data/ asset
164246 id : create_release_large
165247 run : |
@@ -201,33 +283,11 @@ jobs:
201283 echo "Finding: ${{ steps.scan_asset_large.outputs.finding }}"
202284 fi
203285
204- # Cleanup: Delete test release
205- - name : Cleanup test release
206- if : steps.create_release.outcome == 'success'
207- run : |
208- if [ -n "${{ steps.create_release.outputs.tag_name }}" ]; then
209- gh release delete "${{ steps.create_release.outputs.tag_name }}" --yes --cleanup-tag || true
210- fi
211- env :
212- GH_TOKEN : ${{ github.token }}
213-
214- - name : Cleanup large artifact file
215- if : steps.upload_artifact_large.outcome == 'success'
216- run : |
217- if [ -n "${{ steps.upload_artifact_large.outputs.artifact-id }}" ]; then
218- curl -L \
219- -X DELETE \
220- -H "Accept: application/vnd.github+json" \
221- -H "Authorization: Bearer ${{ github.token }}" \
222- -H "X-GitHub-Api-Version: 2022-11-28" \
223- https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ steps.upload_artifact_large.outputs.artifact-id }}
224- fi
225-
226286 - name : Cleanup large release
227- if : steps.create_release_large.outcome == 'success'
287+ if : always() && steps.create_release_large.outcome == 'success'
228288 run : |
229289 if [ -n "${{ steps.create_release_large.outputs.tag_name }}" ]; then
230290 gh release delete "${{ steps.create_release_large.outputs.tag_name }}" --yes --cleanup-tag || true
231291 fi
232292 env :
233- GH_TOKEN : ${{ github.token }}
293+ GH_TOKEN : ${{ github.token }}
0 commit comments