Skip to content

Commit e28456c

Browse files
committed
Test CI.
1 parent a19ff66 commit e28456c

File tree

4 files changed

+104
-75
lines changed

4 files changed

+104
-75
lines changed

.github/workflows/requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ lxml_html_clean
55
notebook>=6.5,<7
66
traitlets==5.14.3
77
jupyter
8-
jupyter_contrib_nbextensions
98
nbconvert
10-
ipython-sql
119
papermill

.github/workflows/run_notebooks.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Run Notebooks Reusable Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
required: true
8+
type: string
9+
notebooks:
10+
required: true
11+
type: string
12+
docker-run-line:
13+
required: false
14+
type: string
15+
additional-requirements:
16+
required: false
17+
type: string
18+
19+
jobs:
20+
21+
build-notebooks:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
python: ${{ fromJSON(inputs.python-versions) }}
26+
notebook: ${{ fromJSON(inputs.notebooks) }}
27+
28+
steps:
29+
- name: Checkout the repo.
30+
uses: actions/checkout@v4
31+
32+
- name: Setup optional docker container
33+
run: |
34+
test -n "${{ inputs.docker-run-line }}" ] && \
35+
docker run --rm -d ${{ inputs.docker-run-line }}
36+
37+
- name: Setup Python
38+
uses: actions/[email protected]
39+
with:
40+
python-version: '${{ matrix.python }}'
41+
cache: 'pip'
42+
43+
- name: Install dependencies
44+
run: |
45+
python3 -m pip install --upgrade pip
46+
pip install -r .github/workflows/requirements.txt
47+
test -n "${{ inputs.additional-requirements }}" ] && \
48+
pip install ${{ inputs.additional-requirements }}
49+
50+
- name: Create output directory
51+
run: mkdir -p ${{RUNNER.temp}}/nb-runner
52+
env:
53+
RUNNER: ${{ toJson(runner) }}
54+
55+
- name: Run notebook
56+
run: |
57+
papermill ${{ matrix.notebook }} ${{matrix.notebook}}.output.ipynb
58+
59+
- name: Convert notebook to HTML
60+
run: |
61+
jupyter nbconvert --to html ${{ matrix.notebook }}.output.ipynb
62+
cp ${{ matrix.notebook }}* ${{ RUNNER.temp }}/nb-runner
63+
env:
64+
RUNNER: ${{ toJson(runner) }}
65+
66+
- name: Convert notebook mame to artifact name to avoid colisions
67+
id: gen-output-artifact-name
68+
run: |
69+
echo "notebook-no-slash=`echo "${{ matrix.notebook }}" | tr '/. ' '---'`" >> "$GITHUB_OUTPUT"
70+
71+
- name: Upload artifacts
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: output-notebooks-${{ steps.gen-output-artifact-name.outputs.notebook-no-slash }}-py-${{ matrix.python }}
75+
path: ${{ RUNNER.temp }}/nb-runner
76+
env:
77+
RUNNER: ${{ toJson(runner) }}

.github/workflows/run_notebooks_sql.yml

Lines changed: 26 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ on:
44
push:
55
branches: [ '*' ]
66
paths:
7-
- 'sql/**'
7+
- 'sql/*.ipynb'
8+
- 'intro/*.ipynb'
89
pull_request:
910
branches: [ '*' ]
1011
paths:
11-
- 'sql/**'
12+
- 'sql/*.ipynb'
13+
- 'intro/*.ipynb'
1214

1315
jobs:
1416
dump_contexts_to_log:
@@ -39,78 +41,31 @@ jobs:
3941
MATRIX_CONTEXT: ${{ toJson(matrix) }}
4042
run: echo "$MATRIX_CONTEXT"
4143

42-
build-sql-notebooks:
44+
setup-modified-files:
4345
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-
5946
steps:
47+
- name: Checkout the repo.
48+
uses: actions/checkout@v4
6049

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-
uses: actions/[email protected]
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'
7856

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 }}"
8459

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 }}
9063

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"

sql/sesion1.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"id": "NVBsiBj1IWqc"
2525
},
2626
"source": [
27-
"Esta hoja muestra cómo acceder a bases de datos SQL y también a conectar la salida con Jupyter. Las partes en SQL también se pueden realizar directamente en MySQL ejecutando el programa `mysql` del entorno de ejecución.\n",
28-
"\n"
27+
"Esta hoja muestra cómo acceder a bases de datos SQL y también a conectar la salida con Jupyter. Las partes en SQL también se pueden realizar directamente en MySQL ejecutando el programa `mysql` del entorno de ejecución.\n"
2928
]
3029
},
3130
{

0 commit comments

Comments
 (0)