Skip to content

Commit

Permalink
#307 Made each notebook test a separate job (#312)
Browse files Browse the repository at this point in the history
* #307 Made each notebook test a separate job

* #307 Made each notebook test a separate job

* #307 Made each notebook test a separate job

* #307 Made each notebook test a separate job

* #307 Made each notebook test a separate job

* #307 Removed conftest.py

* #307 Changed run syntax

* #307 Restored conftest.py

* #307 Restored conftest.py

* #307 Added the rest of the notebook tests

* [code build]

* [CodeBuild]

* [CodeBuild]

* #307 Turned the notebook tests into a matrix

* #307 [CodeBuild]

* #307 Updated the changelog [CodeBuild]
  • Loading branch information
ahsimb committed Jul 30, 2024
1 parent 6b31cd0 commit 20b9905
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 91 deletions.
31 changes: 31 additions & 0 deletions .github/actions/prepare_test_env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Prepare Test Environment'
description: 'A custom action performing common steps required for running tests'

runs:
using: 'composite'
steps:
- name: Free disk space with jlumbroso
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false

- name: Free disk space by removing large directories
run: |
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /opt/ghc
shell: bash

- name: Show available disk space
run: df -h
shell: bash

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@0.13.0
with:
python-version: "3.10"
poetry-version: "1.8.2"
99 changes: 16 additions & 83 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,20 @@ jobs:
needs: run-unit-tests

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false

- name: Free disk space by removing large directories
run: |
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /opt/ghc
- name: Show available disk space
run: df -h

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@0.13.0
with:
python-version: "3.10"
poetry-version: "1.8.2"

- name: Run Integration Tests
run: >
poetry run pytest
--capture=no
--override-ini=log_cli=true
--override-ini=log_cli_level=INFO
test/integration
env: # Set the secret as an env variable
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/prepare_test_env/

- name: Run Integration Tests
run: >
poetry run pytest
--capture=no
--override-ini=log_cli=true
--override-ini=log_cli_level=INFO
test/integration
env: # Set the secret as an env variable
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
Expand All @@ -90,55 +68,10 @@ jobs:
approve-test-execution

run-notebook-tests:
name: Jupyter Notebook Tests
environment: AWS_SAGEMAKER
runs-on: ubuntu-latest
uses: ./.github/workflows/notebook_tests.yaml
secrets: inherit
needs: approval-for-notebook-tests

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false

- name: Free disk space by removing large directories
run: |
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /opt/ghc
- name: Show available disk space
run: df -h

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@0.13.0
with:
python-version: "3.10"
poetry-version: "1.8.2"

- name: Run notebook tests
run: >
poetry run pytest
--capture=no
--override-ini=log_cli=true
--override-ini=log_cli_level=INFO
test/notebook_test_runner/test_notebooks_in_dss_docker_image.py
env: # Set the secret as an env variable
NBTEST_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
NBTEST_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
NBTEST_AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
SAAS_ACCOUNT_ID: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_ACCOUNT_ID }}
SAAS_PAT: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_PAT }}

gate-2:
name: Gate 2 - Allow Merge
runs-on: ubuntu-latest
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/notebook_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Notebook Tests

on:
workflow_call:

jobs:
notebook_tests:
environment: AWS_SAGEMAKER
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nb_test:
- { name: "sklearn notebook", test_file: "nbtest_sklearn.py" }
- { name: "ibis notebook", test_file: "nbtest_ibis.py" }
- { name: "SLC notebook", test_file: "nbtest_script_languages_container.py" }
- { name: "short notebook tests", test_file: "\"nbtest_environment_test.py nbtest_itde.py\""}
name: Running ${{ matrix.nb_test.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/prepare_test_env/

- name: Run notebook tests
run: |
poetry run pytest \
--capture=no \
--override-ini=log_cli=true \
--override-ini=log_cli_level=INFO \
--nb-test-file=${{ matrix.nb_test.test_file }} \
test/notebook_test_runner/test_notebooks_in_dss_docker_image.py
env:
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
SAAS_ACCOUNT_ID: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_ACCOUNT_ID }}
SAAS_PAT: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_PAT }}
NBTEST_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
NBTEST_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
NBTEST_AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
2 changes: 2 additions & 0 deletions doc/changes/changes_2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ Version: 2.1.0
* #295: Made notebook-tests mandatory for merge
* #193: Ignored warnings in notebook tests
* #297: Reduced log level for transitive libraries in notebook tests
* #307: Made the notebook tests running in parallel;
moved common steps from test jobs to a composite action
10 changes: 10 additions & 0 deletions test/notebook_test_runner/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest


def pytest_addoption(parser):
parser.addoption("--nb-test-file", action="store", help="Notebook test file nbtest_*.py")


@pytest.fixture
def notebook_test_file(request):
return request.config.getoption("--nb-test-file")
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ def notebook_test_container_with_log(notebook_test_container):
yield container


@pytest.mark.parametrize(
"notebook_test_file",
[
python_file.name
for python_file in sorted(TEST_RESOURCE_PATH.glob("nbtest_*.py"))
if python_file.is_file()
]
)
def test_notebook(notebook_test_container_with_log, notebook_test_file):
_logger.info(f"Running notebook tests for {notebook_test_file}")
container = notebook_test_container_with_log
Expand Down

0 comments on commit 20b9905

Please sign in to comment.