Skip to content

Commit

Permalink
add and use exasol toolbox (#78)
Browse files Browse the repository at this point in the history
fixes #77
  • Loading branch information
Jannis-Mittenzwei authored Nov 29, 2024
1 parent a86beb5 commit 2ecf716
Show file tree
Hide file tree
Showing 85 changed files with 3,985 additions and 1,761 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Run Unit Tests
run: poetry run nox -s test:unit

- name: Run Lint
run: poetry run nox -s lint:code

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

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ".lint-python-${{ matrix.python-version }}.txt"
path: .lint.txt
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
.pytest_cache
.gitignore
dist
__pycache__
__pycache__.html-documentation
.lint.txt
.lint.json
.security.json
.coverage
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
1 change: 1 addition & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* [1.6.0](changes_1.6.0.md)
* [1.5.0](changes_1.5.0.md)
* [1.4.0](changes_1.4.0.md)
* [1.3.1](changes_1.3.1.md)
Expand Down
27 changes: 27 additions & 0 deletions doc/changes/changes_1.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# script-languages-container-ci-setup 1.6.0, tbd.

Code name: tbd

## Summary

tbd

## Bug Fixes

n/a

## Features / Enhancements

n/a

## Documentation

n/a

## Refactoring

n/a

## Dependencies

n/a
14 changes: 7 additions & 7 deletions exasol_script_languages_container_ci_setup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from exasol_script_languages_container_ci_setup.cli.commands import (
health,
generate_buildspec,
generate_release_buildspec,
deploy_source_credentials,
deploy_ci_build,
deploy_release_build,
deploy_source_credentials,
generate_buildspec,
generate_release_buildspec,
health,
start_ci_build,
start_release_build,
start_test_release_build,
validate_ci_build,
validate_release_build,
validate_source_credentials,
start_release_build,
start_test_release_build,
start_ci_build
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,38 @@

from exasol_script_languages_container_ci_setup.cli.cli import cli
from exasol_script_languages_container_ci_setup.cli.common import add_options
from exasol_script_languages_container_ci_setup.cli.options.logging import logging_options, set_log_level
from exasol_script_languages_container_ci_setup.cli.options.aws_options import (
aws_options,
)
from exasol_script_languages_container_ci_setup.cli.options.logging import (
logging_options,
set_log_level,
)
from exasol_script_languages_container_ci_setup.lib.aws.aws_access import AwsAccess
from exasol_script_languages_container_ci_setup.lib.ci_build import run_deploy_ci_build
from exasol_script_languages_container_ci_setup.cli.options.aws_options import aws_options


@cli.command()
@add_options(aws_options)
@add_options(logging_options)
@click.option('--project', type=str, required=True,
help="""The project for which the stack will be created.""")
@click.option('--project-url', type=str, required=True,
help="""The URL of the project on Github.""")
@click.option(
"--project",
type=str,
required=True,
help="""The project for which the stack will be created.""",
)
@click.option(
"--project-url",
type=str,
required=True,
help="""The URL of the project on Github.""",
)
def deploy_ci_build(
aws_profile: Optional[str],
log_level: str,
project: str,
project_url: str):
aws_profile: Optional[str], log_level: str, project: str, project_url: str
):
set_log_level(log_level)
try:
run_deploy_ci_build(AwsAccess(aws_profile), project,
project_url)
run_deploy_ci_build(AwsAccess(aws_profile), project, project_url)
except Exception:
logging.error("run_deploy_ci_build failed.")
sys.exit(1)
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,37 @@

from exasol_script_languages_container_ci_setup.cli.cli import cli
from exasol_script_languages_container_ci_setup.cli.common import add_options
from exasol_script_languages_container_ci_setup.cli.options.logging import logging_options, set_log_level
from exasol_script_languages_container_ci_setup.cli.options.aws_options import (
aws_options,
)
from exasol_script_languages_container_ci_setup.cli.options.logging import (
logging_options,
set_log_level,
)
from exasol_script_languages_container_ci_setup.lib.aws.aws_access import AwsAccess
from exasol_script_languages_container_ci_setup.cli.options.aws_options import aws_options
from exasol_script_languages_container_ci_setup.lib.release_build import run_deploy_release_build
from exasol_script_languages_container_ci_setup.lib.release_build import (
run_deploy_release_build,
)


@cli.command()
@add_options(aws_options)
@add_options(logging_options)
@click.option('--project', type=str, required=True,
help="""The project for which the stack will be created.""")
@click.option('--project-url', type=str, required=True,
help="""The URL of the project on Github.""")
@click.option(
"--project",
type=str,
required=True,
help="""The project for which the stack will be created.""",
)
@click.option(
"--project-url",
type=str,
required=True,
help="""The URL of the project on Github.""",
)
def deploy_release_build(
aws_profile: Optional[str],
log_level: str,
project: str,
project_url: str):
aws_profile: Optional[str], log_level: str, project: str, project_url: str
):
set_log_level(log_level)
try:
run_deploy_release_build(AwsAccess(aws_profile), project, project_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,52 @@

from exasol_script_languages_container_ci_setup.cli.cli import cli
from exasol_script_languages_container_ci_setup.cli.common import add_options
from exasol_script_languages_container_ci_setup.cli.options.logging import logging_options, set_log_level
from exasol_script_languages_container_ci_setup.cli.options.aws_options import (
aws_options,
)
from exasol_script_languages_container_ci_setup.cli.options.logging import (
logging_options,
set_log_level,
)
from exasol_script_languages_container_ci_setup.lib.aws.aws_access import AwsAccess
from exasol_script_languages_container_ci_setup.lib.source_credentials import run_deploy_source_credentials
from exasol_script_languages_container_ci_setup.cli.options.aws_options import aws_options
from exasol_script_languages_container_ci_setup.lib.source_credentials import (
run_deploy_source_credentials,
)


@cli.command()
@add_options(aws_options)
@add_options(logging_options)
@click.option('--secret-name', required=True, type=str,
help="Secret stored in AWS Secret Manager.")
@click.option('--secret-user-key', required=True, type=str,
help="User key stored as secret in AWS Secret Manager.")
@click.option('--secret-token-key', required=True, type=str,
help="Token key stored as secret in AWS Secret Manager.")
@click.option(
"--secret-name",
required=True,
type=str,
help="Secret stored in AWS Secret Manager.",
)
@click.option(
"--secret-user-key",
required=True,
type=str,
help="User key stored as secret in AWS Secret Manager.",
)
@click.option(
"--secret-token-key",
required=True,
type=str,
help="Token key stored as secret in AWS Secret Manager.",
)
def deploy_source_credentials(
aws_profile: Optional[str],
log_level: str,
secret_name: str,
secret_user_key: str,
secret_token_key: str):
aws_profile: Optional[str],
log_level: str,
secret_name: str,
secret_user_key: str,
secret_token_key: str,
):
set_log_level(log_level)
try:
run_deploy_source_credentials(AwsAccess(aws_profile), secret_name, secret_user_key, secret_token_key)
run_deploy_source_credentials(
AwsAccess(aws_profile), secret_name, secret_user_key, secret_token_key
)
except Exception:
logging.error("deploy_source_credentials failed.")
sys.exit(1)

Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
from pathlib import Path
from typing import Tuple, Optional
from typing import (
Optional,
Tuple,
)

import click

from exasol_script_languages_container_ci_setup.cli.cli import cli
from exasol_script_languages_container_ci_setup.cli.common import add_options
from exasol_script_languages_container_ci_setup.cli.options.logging import logging_options, set_log_level
from exasol_script_languages_container_ci_setup.lib.run_generate_buildspec import run_generate_buildspec
from exasol_script_languages_container_ci_setup.cli.options.logging import (
logging_options,
set_log_level,
)
from exasol_script_languages_container_ci_setup.lib.run_generate_buildspec import (
run_generate_buildspec,
)


@cli.command()
@add_options(logging_options)
@click.option('--flavor-root-path', required=True, multiple=True,
type=click.Path(file_okay=False, dir_okay=True, exists=True),
help="Path where script language container flavors are located.")
@click.option('--output-path', type=click.Path(file_okay=False, dir_okay=True, exists=True, writable=True),
default="./aws-code-build/ci", show_default=True,
help="Path where buildspec files will be deployed.")
@click.option('--config-file', type=click.Path(file_okay=True, dir_okay=False, exists=True),
help="Configuration file for build (project specific).")
@click.option(
"--flavor-root-path",
required=True,
multiple=True,
type=click.Path(file_okay=False, dir_okay=True, exists=True),
help="Path where script language container flavors are located.",
)
@click.option(
"--output-path",
type=click.Path(file_okay=False, dir_okay=True, exists=True, writable=True),
default="./aws-code-build/ci",
show_default=True,
help="Path where buildspec files will be deployed.",
)
@click.option(
"--config-file",
type=click.Path(file_okay=True, dir_okay=False, exists=True),
help="Configuration file for build (project specific).",
)
def generate_buildspecs(
flavor_root_path: Tuple[str, ...],
log_level: str,
output_path: str,
config_file: Optional[str]
):
flavor_root_path: Tuple[str, ...],
log_level: str,
output_path: str,
config_file: Optional[str],
):
"""
This command generates the buildspec file(s) for AWS CodeBuild based on the flavors located in path "flavor_root_path".
"""
set_log_level(log_level)
run_generate_buildspec(flavor_root_path, output_path, config_file)

Loading

0 comments on commit 2ecf716

Please sign in to comment.