|
| 1 | +name: Test utility scripts |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + types: |
| 7 | + # We want this workflow triggered if the 'infrastructure' label is added |
| 8 | + # or present when PR is updated |
| 9 | + - opened |
| 10 | + - reopened |
| 11 | + - synchronize |
| 12 | + - labeled |
| 13 | + |
| 14 | +jobs: |
| 15 | + notebooks: |
| 16 | + |
| 17 | + # get_modified_tutorials.py |
| 18 | + name: "Test get_modified_tutorials.py script" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: contains(github.event.pull_request.labels.*.name, 'infrastructure') |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v2 |
| 28 | + with: |
| 29 | + python-version: 3.9 |
| 30 | + |
| 31 | + - name: Install dependencies and setup |
| 32 | + run: | |
| 33 | + sudo apt-get install pandoc |
| 34 | + python -m pip install -U pip |
| 35 | + python -m pip install gitpython |
| 36 | + git config --global user.email "bot@robot.com" |
| 37 | + git config --global user.name "Botty McBotface" |
| 38 | +
|
| 39 | + # Make sure if a file is removed, it does not appear in the modified list: |
| 40 | + - name: Test 1a - removed (staged) |
| 41 | + run: | |
| 42 | + git rm tutorials/FITS-header/FITS-header.ipynb |
| 43 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 44 | + [ ! -z "$MODIFIED" ] && exit 1 || echo "Success!" |
| 45 | + git reset --hard HEAD |
| 46 | +
|
| 47 | + - name: Test 1b - removed and committed |
| 48 | + run: | |
| 49 | + git rm tutorials/FITS-header/FITS-header.ipynb |
| 50 | + git commit -m "TEST COMMIT" |
| 51 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 52 | + [ ! -z "$MODIFIED" ] && exit 1 || echo "Success!" |
| 53 | + git reset --hard HEAD~1 |
| 54 | +
|
| 55 | + # Make sure if a file is modified, it appears in the modified list: |
| 56 | + - name: Test 2a - edited |
| 57 | + run: | |
| 58 | + echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb |
| 59 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 60 | + [ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!" |
| 61 | + git reset --hard HEAD |
| 62 | +
|
| 63 | + - name: Test 2b - edited and staged |
| 64 | + run: | |
| 65 | + echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb |
| 66 | + git add tutorials/FITS-header/FITS-header.ipynb |
| 67 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 68 | + [ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!" |
| 69 | + git reset --hard HEAD |
| 70 | +
|
| 71 | + - name: Test 2c - edited and committed |
| 72 | + run: | |
| 73 | + echo "TEST" >> tutorials/FITS-header/FITS-header.ipynb |
| 74 | + git add tutorials/FITS-header/FITS-header.ipynb |
| 75 | + git commit -m "TEST COMMIT" |
| 76 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 77 | + [ "$MODIFIED" != "tutorials/FITS-header/FITS-header.ipynb" ] && exit 1 || echo "Success!" |
| 78 | + git reset --hard HEAD~1 |
| 79 | +
|
| 80 | + # Make sure if a file is created, it appears in the modified list: |
| 81 | + - name: Test 3a - created and staged |
| 82 | + run: | |
| 83 | + touch tutorials/FITS-header/FITS-header2.ipynb |
| 84 | + git add tutorials/FITS-header/FITS-header2.ipynb |
| 85 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 86 | + [ "$MODIFIED" != "tutorials/FITS-header/FITS-header2.ipynb" ] && exit 1 || echo "Success!" |
| 87 | + git reset --hard HEAD |
| 88 | +
|
| 89 | + - name: Test 3b - created and committed |
| 90 | + run: | |
| 91 | + touch tutorials/FITS-header/FITS-header2.ipynb |
| 92 | + git add tutorials/FITS-header/FITS-header2.ipynb |
| 93 | + git commit -m "TEST COMMIT" |
| 94 | + MODIFIED=$(python .github/get_modified_tutorials.py --main-branch origin/main) |
| 95 | + [ "$MODIFIED" != "tutorials/FITS-header/FITS-header2.ipynb" ] && exit 1 || echo "Success!" |
| 96 | + git reset --hard HEAD~1 |
0 commit comments