Skip to content

Commit

Permalink
Use exasol-toolbox (#226)
Browse files Browse the repository at this point in the history
* Added exasol-toolbox
  • Loading branch information
tomuben authored Aug 27, 2024
1 parent ee63191 commit db3b23c
Show file tree
Hide file tree
Showing 112 changed files with 5,405 additions and 2,538 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Checks

on:
pull_request:

jobs:

lint-job:
name: Linting and Type checks (Python-${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: SCM Checkout
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@0.14.0
with:
python-version: ${{ matrix.python-version }}

- name: Run Tests
run: poetry run nox -s lint

- name: Run type-check
run: poetry run nox -s type-check

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ".lint-python-${{ matrix.python-version }}.txt"
path: .lint.txt
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@ dmypy.json
.build_output/

# Emacs
TAGS
TAGS

.lint.json
.lint.txt
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
default_stages: [ commit ]
repos:

- repo: local
hooks:
- id: code-format
name: code-format
types: [ python ]
pass_filenames: false
language: system
entry: poetry run nox -s fix

- repo: local
hooks:
- id: type-check
name: type-check
types: [ python ]
pass_filenames: false
language: system
entry: poetry run nox -s type-check

- repo: local
hooks:
- id: lint
name: lint
types: [ python ]
pass_filenames: false
language: system
entry: poetry run nox -s lint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ You can build, export and upload script-language container from so-called flavor
which are description how to build the script language container. You can find pre-defined flavors
in the [script-languages-release](https://github.com/exasol/script-languages-release) repository.
There we also described how you could customize these flavors to your needs.
<h1 align="center">Exasol Toolbox</h1>

<p align="center">
Building script-language container for extending Exasol UDFs.
</p>

<p align="center">

<a href="https://github.com/exasol/script-languages-container-tool/actions/workflows/ci.yml">
<img src="https://github.com/exasol/script-languages-container-tool/actions/workflows/main.yml/badge.svg?branch=main" alt="Checks Main">
</a>
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/pypi/l/exasol-script-languages-container-tool" alt="License">
</a>
<a href="https://pypi.org/project/exasol-script-languages-container-tool/">
<img src="https://img.shields.io/pypi/dm/exasol-script-languages-container-tool" alt="Downloads">
</a>
<a href="https://pypi.org/project/exasol-script-languages-container-tool/">
<img src="https://img.shields.io/pypi/pyversions/exasol-script-languages-container-tool" alt="Supported Python Versions">
</a>
<a href="https://pypi.org/project/exasol-script-languages-container-tool/">
<img src="https://img.shields.io/pypi/v/exasol-script-languages-container-tool" alt="PyPi Package">
</a>
</p>


## In a Nutshell

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from .build import build
from .build_test_container import build_test_container
from .clean import clean_all_images, clean_flavor_images
from .export import export
from .generate_language_activation import generate_language_activation
from .install_starter_scripts import install_starter_scripts
from .push import push
from .push_test_container import push_test_container
from .run_db_tests import run_db_test
from .save import save
from .upload import upload
from .security_scan import security_scan
from .install_starter_scripts import install_starter_scripts
from .build_test_container import build_test_container
from .push_test_container import push_test_container
from .upload import upload
146 changes: 81 additions & 65 deletions exasol_script_languages_container_tool/cli/commands/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
from typing import Tuple, Optional
from typing import Optional, Tuple

import click
from exasol_integration_test_docker_environment.cli.cli import cli
from exasol_integration_test_docker_environment.cli.options.build_options import build_options
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import docker_repository_options
from exasol_integration_test_docker_environment.cli.options.system_options import system_options, luigi_logging_options
from exasol_integration_test_docker_environment.cli.termination_handler import TerminationHandler
from exasol_integration_test_docker_environment.cli.options.build_options import (
build_options,
)
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import (
docker_repository_options,
)
from exasol_integration_test_docker_environment.cli.options.system_options import (
luigi_logging_options,
system_options,
)
from exasol_integration_test_docker_environment.cli.termination_handler import (
TerminationHandler,
)
from exasol_integration_test_docker_environment.lib.api.common import add_options

from exasol_script_languages_container_tool.cli.options.flavor_options import flavor_options
from exasol_script_languages_container_tool.cli.options.flavor_options import (
flavor_options,
)
from exasol_script_languages_container_tool.cli.options.goal_options import goal_options
from exasol_script_languages_container_tool.lib import api

Expand All @@ -17,71 +28,76 @@
@add_options(flavor_options)
@add_options(goal_options)
@add_options(build_options)
@click.option('--shortcut-build/--no-shortcut-build', default=True,
help="Forces the system to complete to build all all stages, "
"but not to rebuild them. If the target images are locally available "
"they will be used as is. If the source images locally available "
"they will be taged with target image name. "
"If the source images can be loaded from file or pulled from a docker registry "
"they will get loaded or pulled. The only case, in which them get builded is "
"when they are not otherwise available. "
"This includes the case where a higher stage which transitivily "
"depends on a images is somewhere available, "
"but the images as self is not available.")
@click.option(
"--shortcut-build/--no-shortcut-build",
default=True,
help="Forces the system to complete to build all all stages, "
"but not to rebuild them. If the target images are locally available "
"they will be used as is. If the source images locally available "
"they will be taged with target image name. "
"If the source images can be loaded from file or pulled from a docker registry "
"they will get loaded or pulled. The only case, in which them get builded is "
"when they are not otherwise available. "
"This includes the case where a higher stage which transitivily "
"depends on a images is somewhere available, "
"but the images as self is not available.",
)
@add_options(docker_repository_options)
@add_options(system_options)
@add_options(luigi_logging_options)
def build(flavor_path: Tuple[str, ...],
goal: Tuple[str, ...],
force_rebuild: bool,
force_rebuild_from: Tuple[str, ...],
force_pull: bool,
output_directory: str,
temporary_base_directory: str,
log_build_context_content: bool,
cache_directory: Optional[str],
build_name: Optional[str],
shortcut_build: bool,
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
workers: int,
task_dependencies_dot_file: Optional[str],
log_level: Optional[str],
use_job_specific_log_file: bool
):
def build(
flavor_path: Tuple[str, ...],
goal: Tuple[str, ...],
force_rebuild: bool,
force_rebuild_from: Tuple[str, ...],
force_pull: bool,
output_directory: str,
temporary_base_directory: str,
log_build_context_content: bool,
cache_directory: Optional[str],
build_name: Optional[str],
shortcut_build: bool,
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
workers: int,
task_dependencies_dot_file: Optional[str],
log_level: Optional[str],
use_job_specific_log_file: bool,
):
"""
This command builds all stages of the script-language-container flavor.
If stages are cached in a docker registry, this command is going to pull them,
instead of building them.
"""
with TerminationHandler():
api.build(flavor_path=flavor_path,
goal=goal,
force_rebuild=force_rebuild,
force_rebuild_from=force_rebuild_from,
force_pull=force_pull,
output_directory=output_directory,
temporary_base_directory=temporary_base_directory,
log_build_context_content=log_build_context_content,
cache_directory=cache_directory,
build_name=build_name,
shortcut_build=shortcut_build,
source_docker_repository_name=source_docker_repository_name,
source_docker_tag_prefix=source_docker_tag_prefix,
source_docker_username=source_docker_username,
source_docker_password=source_docker_password,
target_docker_repository_name=target_docker_repository_name,
target_docker_tag_prefix=target_docker_tag_prefix,
target_docker_username=target_docker_username,
target_docker_password=target_docker_password,
workers=workers,
task_dependencies_dot_file=task_dependencies_dot_file,
log_level=log_level,
use_job_specific_log_file=use_job_specific_log_file
)
api.build(
flavor_path=flavor_path,
goal=goal,
force_rebuild=force_rebuild,
force_rebuild_from=force_rebuild_from,
force_pull=force_pull,
output_directory=output_directory,
temporary_base_directory=temporary_base_directory,
log_build_context_content=log_build_context_content,
cache_directory=cache_directory,
build_name=build_name,
shortcut_build=shortcut_build,
source_docker_repository_name=source_docker_repository_name,
source_docker_tag_prefix=source_docker_tag_prefix,
source_docker_username=source_docker_username,
source_docker_password=source_docker_password,
target_docker_repository_name=target_docker_repository_name,
target_docker_tag_prefix=target_docker_tag_prefix,
target_docker_username=target_docker_username,
target_docker_password=target_docker_password,
workers=workers,
task_dependencies_dot_file=task_dependencies_dot_file,
log_level=log_level,
use_job_specific_log_file=use_job_specific_log_file,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
from typing import Tuple, Optional
from typing import Optional, Tuple

from exasol_integration_test_docker_environment.cli.cli import cli
from exasol_integration_test_docker_environment.cli.options.build_options import build_options
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import docker_repository_options
from exasol_integration_test_docker_environment.cli.options.system_options import system_options, luigi_logging_options
from exasol_integration_test_docker_environment.cli.termination_handler import TerminationHandler
from exasol_integration_test_docker_environment.cli.options.build_options import (
build_options,
)
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import (
docker_repository_options,
)
from exasol_integration_test_docker_environment.cli.options.system_options import (
luigi_logging_options,
system_options,
)
from exasol_integration_test_docker_environment.cli.termination_handler import (
TerminationHandler,
)
from exasol_integration_test_docker_environment.lib.api.common import add_options

from exasol_script_languages_container_tool.cli.options.test_container_options import test_container_options
from exasol_script_languages_container_tool.cli.options.test_container_options import (
test_container_options,
)
from exasol_script_languages_container_tool.lib import api


Expand All @@ -18,27 +29,27 @@
@add_options(system_options)
@add_options(luigi_logging_options)
def build_test_container(
test_container_folder: str,
force_rebuild: bool,
force_rebuild_from: Tuple[str, ...],
force_pull: bool,
output_directory: str,
temporary_base_directory: str,
log_build_context_content: bool,
cache_directory: Optional[str],
build_name: Optional[str],
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
workers: int,
task_dependencies_dot_file: Optional[str],
log_level: Optional[str],
use_job_specific_log_file: bool
test_container_folder: str,
force_rebuild: bool,
force_rebuild_from: Tuple[str, ...],
force_pull: bool,
output_directory: str,
temporary_base_directory: str,
log_build_context_content: bool,
cache_directory: Optional[str],
build_name: Optional[str],
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
workers: int,
task_dependencies_dot_file: Optional[str],
log_level: Optional[str],
use_job_specific_log_file: bool,
):
"""
Builds the test container docker image.
Expand Down Expand Up @@ -67,5 +78,5 @@ def build_test_container(
workers=workers,
task_dependencies_dot_file=task_dependencies_dot_file,
log_level=log_level,
use_job_specific_log_file=use_job_specific_log_file
use_job_specific_log_file=use_job_specific_log_file,
)
Loading

0 comments on commit db3b23c

Please sign in to comment.