|
4 | 4 | push:
|
5 | 5 | branches: [ '*' ]
|
6 | 6 | paths:
|
7 |
| - - 'sql/**' |
| 7 | + - 'sql/*.ipynb' |
| 8 | + - 'intro/*.ipynb' |
8 | 9 | pull_request:
|
9 | 10 | branches: [ '*' ]
|
10 | 11 | paths:
|
11 |
| - - 'sql/**' |
| 12 | + - 'sql/*.ipynb' |
| 13 | + - 'intro/*.ipynb' |
12 | 14 |
|
13 | 15 | jobs:
|
14 | 16 | dump_contexts_to_log:
|
@@ -39,78 +41,31 @@ jobs:
|
39 | 41 | MATRIX_CONTEXT: ${{ toJson(matrix) }}
|
40 | 42 | run: echo "$MATRIX_CONTEXT"
|
41 | 43 |
|
42 |
| - build-sql-notebooks: |
| 44 | + setup-modified-files: |
43 | 45 | runs-on: ubuntu-latest
|
44 |
| - env: |
45 |
| - DB_HOSTNAME: "127.0.0.1" |
46 |
| - services: |
47 |
| - mysql: |
48 |
| - image: mysql:8 |
49 |
| - env: |
50 |
| - MYSQL_ROOT_PASSWORD: root |
51 |
| - ports: |
52 |
| - - 3306:3306 |
53 |
| - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
54 |
| - strategy: |
55 |
| - matrix: |
56 |
| - python: ["3.10", "3.12", "3.13"] |
57 |
| - notebook: ["intro/sesion0.ipynb", "sql/sesion1.ipynb", "sql/sesion2.ipynb"] |
58 |
| - |
59 | 46 | steps:
|
| 47 | + - name: Checkout the repo. |
| 48 | + uses: actions/checkout@v4 |
60 | 49 |
|
61 |
| - - name: Checkout the repo. |
62 |
| - uses: actions/checkout@v4 |
63 |
| - |
64 |
| - # Cambiado Notebook? |
65 |
| - - name: ${{ matrix.notebook }} changed? |
66 |
| - id: changed-file |
67 |
| - uses: tj-actions/changed-files@v42 |
68 |
| - with: |
69 |
| - files: | |
70 |
| - ${{ matrix.notebook }} |
71 |
| -
|
72 |
| - - name: Setup Python |
73 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
74 |
| - |
75 |
| - with: |
76 |
| - python-version: '${{ matrix.python }}' |
77 |
| - cache: 'pip' |
| 50 | + - name: Get all changed files. |
| 51 | + id: changed-notebooks |
| 52 | + uses: tj-actions/changed-files@v45 |
| 53 | + with: |
| 54 | + matrix: true |
| 55 | + files: 'sql/**.ipynb' |
78 | 56 |
|
79 |
| - - name: Install dependencies |
80 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
81 |
| - run: | |
82 |
| - python3 -m pip install --upgrade pip |
83 |
| - pip install -r .github/workflows/requirements.txt |
| 57 | + - name: Show all changed files |
| 58 | + run: echo "${{ steps.changed-notebooks.outputs.all_changed_files }}" |
84 | 59 |
|
85 |
| - - name: Create output directory |
86 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
87 |
| - run: mkdir -p ${{RUNNER.temp}}/nb-runner |
88 |
| - env: |
89 |
| - RUNNER: ${{ toJson(runner) }} |
| 60 | + outputs: |
| 61 | + notebooks-any_changed: ${{ steps.changed-notebooks.outputs.any_changed }} |
| 62 | + notebooks-changed: ${{ steps.changed-notebooks.outputs.all_changed_files }} |
90 | 63 |
|
91 |
| - - name: Run notebook |
92 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
93 |
| - run: | |
94 |
| - papermill ${{ matrix.notebook }} ${{ matrix.notebook }}.output.ipynb |
95 |
| -
|
96 |
| - - name: Convert notebook to HTML |
97 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
98 |
| - run: | |
99 |
| - jupyter nbconvert --to html ${{ matrix.notebook }}.output.ipynb |
100 |
| - cp ${{ matrix.notebook }}.output.* ${{RUNNER.temp}}/nb-runner |
101 |
| - env: |
102 |
| - RUNNER: ${{ toJson(runner) }} |
103 |
| - |
104 |
| - - name: Convert notebook mame to artifact name to avoid colisions |
105 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
106 |
| - id: notebook-no-slash |
107 |
| - run: | |
108 |
| - echo "value=`echo "${{ matrix.notebook }}" | tr '/. ' '---'`" >> "$GITHUB_OUTPUT" |
109 |
| -
|
110 |
| - - uses: actions/upload-artifact@v4 |
111 |
| - if: steps.changed-file.outputs.any_changed == 'true' |
112 |
| - with: |
113 |
| - name: output-sql-${{ steps.notebook-no-slash.outputs.value }}-${{ matrix.python }} |
114 |
| - path: ${{ RUNNER.temp }}/nb-runner |
115 |
| - env: |
116 |
| - RUNNER: ${{ toJson(runner) }} |
| 64 | + build-sql-notebooks: |
| 65 | + uses: ./.github/workflows/run_notebooks.yml |
| 66 | + needs: setup-modified-files |
| 67 | + with: |
| 68 | + docker-run-line: "-p3306:3306 -e MYSQL_ROOT_PASSWORD=root --health-cmd='mysqladmin ping' --health-interval=10s --health-timeout=5s --health-retries=3 mysql:8" |
| 69 | + python-versions: '["3.10", "3.12", "3.13"]' |
| 70 | + notebooks: ${{ fromJSON(needs.setup-modified-files.outputs.notebooks-changed) }} |
| 71 | + additional-requirements: "ipython-sql" |
0 commit comments