-
-
Notifications
You must be signed in to change notification settings - Fork 180
96 lines (85 loc) · 3.85 KB
/
test-scripts.yml
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
name: Test utility scripts
on:
pull_request:
branches:
- main
types:
# We want this workflow triggered if the 'infrastructure' label is added
# or present when PR is updated
- opened
- reopened
- synchronize
- labeled
jobs:
notebooks:
# get_modified_tutorials.py
name: "Test get_modified_tutorials.py script"
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'infrastructure')
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.9
- name: Install dependencies and setup
run: |
sudo apt-get install pandoc
python -m pip install -U pip
python -m pip install gitpython
git config --global user.email "bot@robot.com"
git config --global user.name "Botty McBotface"
# Make sure if a file is removed, it does not appear in the modified list:
- name: Test 1a - removed (staged)
run: |
git rm tutorials/FITS-header/FITS-header.ipynb
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ ! -z "$MODIFIED" ] && exit 1 || echo "Success!"
git reset --hard HEAD
- name: Test 1b - removed and committed
run: |
git rm tutorials/FITS-header/FITS-header.ipynb
git commit -m "TEST COMMIT"
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ ! -z "$MODIFIED" ] && exit 1 || echo "Success!"
git reset --hard HEAD~1
# Make sure if a file is modified, it appears in the modified list:
- name: Test 2a - edited
run: |
echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!"
git reset --hard HEAD
- name: Test 2b - edited and staged
run: |
echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb
git add tutorials/FITS-header/FITS-header.ipynb
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!"
git reset --hard HEAD
- name: Test 2c - edited and committed
run: |
echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb
git add tutorials/FITS-header/FITS-header.ipynb
git commit -m "TEST COMMIT"
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!"
git reset --hard HEAD~1
# Make sure if a file is created, it appears in the modified list:
- name: Test 3a - created and staged
run: |
touch tutorials/FITS-header/FITS-header2.ipynb
git add tutorials/FITS-header/FITS-header2.ipynb
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ "$MODIFIED" != "tutorials/FITS-header/FITS-header2.ipynb" ] && exit 1 || echo "Success!"
git reset --hard HEAD
- name: Test 3b - created and committed
run: |
touch tutorials/FITS-header/FITS-header2.ipynb
git add tutorials/FITS-header/FITS-header2.ipynb
git commit -m "TEST COMMIT"
MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main)
[ "$MODIFIED" != "tutorials/FITS-header/FITS-header2.ipynb" ] && exit 1 || echo "Success!"
git reset --hard HEAD~1