-
Notifications
You must be signed in to change notification settings - Fork 15
104 lines (98 loc) · 3.63 KB
/
aslib_data_check.yml
File metadata and controls
104 lines (98 loc) · 3.63 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
# Author: Haniye Kashgarani
# Affiliation: University of Wyoming
# Date: 2023-08-17T15:39:37+00:00
# Github: haniyeka
name: aslib_data_check
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
ASLIB_data_check_tool:
runs-on: ubuntu-latest
#container:
# Docker image that includes python2.7, and libraries like liac-arff, pyyaml, and typing
# This docker also includes files from https://github.com/coseal/aslib-spec/tree/master/data_check_tool_python in /usr/src/app/data_check_tool_python
# image: haniyeka/aslib_data_check:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Run on push
id: get-changes-push
if: github.event_name == 'push'
run: |
echo "This is a push to the main branch."
echo "Previous commit SHA:"
echo ${{ github.event.before }}
echo "Current commit SHA:"
echo ${{ github.sha }}
echo "Get changed directories:"
dirs=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | \
grep -v '^\.github/' | \
grep '/.*$' | \
sed -E 's@(.*)/[^/]*$@\1@' | \
sort -u | \
tr '\n' ' ')
echo "Changed directories: $dirs"
echo "DIRS=$dirs" >> $GITHUB_ENV
- name: Run on pull request
id: get-changes-pull-request
if: github.event_name == 'pull_request'
run: |
echo "This is a pull request to the main branch."
echo "Source branch:"
echo ${{ github.event.pull_request.head.ref }}
echo "Target branch:"
echo ${{ github.event.pull_request.base.ref }}
echo "Get changed directories:"
git fetch origin ${{ github.event.pull_request.base.ref }} # Fetch the target branch
dirs=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \
grep -v '^\.github/' | \
grep '/.*$' | \
sed -E 's@(.*)/[^/]*$@\1@' | \
sort -u | \
tr '\n' ' ')
echo "Changed directories: $dirs"
echo "DIRS=$dirs" >> $GITHUB_ENV
- name: Run on workflow dispatch
id: all-dirs-workflow-dispatch
if: github.event_name == 'workflow_dispatch'
run: |
echo "This workflow was manually triggered."
echo "Get all directories except .git and .github:"
dirs=$(find . -maxdepth 1 -type d \( ! -name . \) \( ! -name .git \) \( ! -name .github \) | sed 's@^\./@@' | tr '\n' ' ')
echo "Directories to check: $dirs"
echo "DIRS=$dirs" >> $GITHUB_ENV
- name: Run data check tool script on directories
run: |
echo "Current directory:"
echo $(pwd)
echo "Scenarios:"
echo $DIRS
if [ -z "$DIRS" ]; then
echo "No scenario is changed or added."
exit 0
fi
docker run -v $(pwd):/workspace -e DIRS="$DIRS" haniyeka/aslib_data_check:latest \
bash -c "
set -e
ls /usr/src/app/data_check_tool_python/src/
echo \$DIRS
for dir in \$DIRS; do
if [ -d \"/workspace/\$dir\" ]; then
hidden_files=\$(find \"/workspace/\$dir/\" -name '.*' -type f)
if [ ! -z \"\$hidden_files\" ]; then
echo 'Error: Hidden files found in' \$dir
echo 'Please remove them and try again!'
exit 1
fi
python /usr/src/app/data_check_tool_python/src/main.py --dir \"/workspace/\$dir\"
fi
done
"