Skip to content

Commit ed2564a

Browse files
Add workflow to check changes in YAML tests (#3)
1 parent d6b5bdb commit ed2564a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/check_tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
name: check_tests
3+
run-name: Check YAML tests have been added/updated to PR
4+
on:
5+
pull_request:
6+
types: [synchronize, labeled, unlabeled]
7+
jobs:
8+
# Check if at least 1 YAML file has been changed
9+
check_changed_templates:
10+
runs-on: ubuntu-latest
11+
if: |
12+
contains(github.event.pull_request.labels.*.name, 'no-test-required') == false
13+
steps:
14+
# Step 1: Checkout the repository @ $GITHUB_WORKSPACE so workflow can access it
15+
- name: Checkout Repository - Fetch history of the current branch
16+
uses: actions/checkout@v4
17+
with:
18+
# Current branch only
19+
ref: ${{ github.ref }}
20+
# Number of commits. 0 indicates all history;
21+
fetch-depth: 0
22+
# Step 2: Get changed YAML files
23+
- name: Get changed YAML files
24+
id: get-changed-yaml-files
25+
uses: tj-actions/changed-files@v46
26+
with:
27+
# Compare against the main branch
28+
base_sha: 'main'
29+
since_last_remote_commit: false
30+
dir_names: false
31+
# Only check for changes to yml/yaml files
32+
files: |
33+
**/*.{yml,yaml}
34+
# Step 3: Print list of changed files (internal maintenance)
35+
- name: Print list of changed yml/yaml files
36+
id: print-changed-yaml-files
37+
run: |
38+
echo "Changed files: ${{ steps.get-changed-yaml-files.outputs.all_changed_files }}"
39+
# Step 4: Confirm if at least 1 YAML file has been changed
40+
- name: Confirm if at least 1 YAML file has been changed
41+
id: yaml_files_changed
42+
run: |
43+
changed_files="${{ steps.get-changed-yaml-files.outputs.all_changed_files }}"
44+
if [ -n "$changed_files" ]; then
45+
echo "YAML files updated"
46+
echo "Changed files: ${{ steps.get-changed-yaml-files.outputs.all_changed_files }}"
47+
exit 0
48+
else
49+
echo "YAML files NOT updated"
50+
exit 1
51+
fi

0 commit comments

Comments
 (0)