Skip to content

Commit bbe4f6e

Browse files
authored
#157: Injected docker credentials to test as environment variables (#158)
Fixes #157
1 parent 6a1f75a commit bbe4f6e

16 files changed

+146
-35
lines changed

.github/workflows/check_setup_py.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
- uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}

.github/workflows/check_version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: true
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
with:
1313
fetch-depth: 0
1414
- name: Setup Python 3.8

.github/workflows/env_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
prep-testbed:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
- id: set-matrix
1212
run: |
1313
sudo apt-get install jq
@@ -23,7 +23,7 @@ jobs:
2323
test-path: ${{fromJson(needs.prep-testbed.outputs.matrix)}}
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727

2828
- name: Run all env tests
2929
run: ./scripts/test/ci_tests/run_ci_test.sh ${{ matrix.test-path }}

.github/workflows/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ jobs:
99
fail-fast: false
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313

1414
- name: Test ./exaslct
1515
run: ./exaslct --help
1616

1717
prep-testbed:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121
- id: set-matrix
2222
run: |
2323
sudo apt-get install jq
@@ -27,6 +27,7 @@ jobs:
2727

2828
test-all:
2929
needs: prep-testbed
30+
environment: ci_test
3031
strategy:
3132
fail-fast: false
3233
matrix:
@@ -37,7 +38,7 @@ jobs:
3738
test-path: ${{fromJson(needs.prep-testbed.outputs.matrix)}}
3839
runs-on: ubuntu-latest
3940
steps:
40-
- uses: actions/checkout@v2
41+
- uses: actions/checkout@v3
4142

4243
- name: Setup Python 3.8 for integration-test-docker-environment
4344
uses: actions/setup-python@v2
@@ -53,13 +54,16 @@ jobs:
5354

5455
- name: Run all tests
5556
run: ./scripts/test/run_test.sh ${{ matrix.test-path }}
57+
env: # Set the secret as an input
58+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
59+
DOCKER_PASSWD: ${{ secrets.DOCKER_PASSWD }}
5660

5761
publish-main:
5862
if: github.ref == 'refs/heads/main'
5963
runs-on: ubuntu-latest
6064
environment: publish
6165
steps:
62-
- uses: actions/checkout@v2
66+
- uses: actions/checkout@v3
6367
- name: Build new Docker image
6468
run: "bash scripts/build/build_docker_runner_image.sh"
6569
- name: Docker login

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
environment: publish
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: Build new Docker image
1515
run: "bash scripts/build/build_docker_runner_image.sh"
1616
- name: Docker login

.github/workflows/release_droid_upload_github_release_assets.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
check-release:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
with:
1616
fetch-depth: 0
1717
- name: Setup Python 3.8 for integration-test-docker-environment
@@ -28,15 +28,15 @@ jobs:
2828
test-docker-starter:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v3
3232

3333
- name: Test ./exaslct
3434
run: ./exaslct --help
3535

3636
prep-testbed:
3737
runs-on: ubuntu-latest
3838
steps:
39-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v3
4040
- id: set-matrix
4141
run: |
4242
sudo apt-get install jq
@@ -46,6 +46,7 @@ jobs:
4646

4747
test-all:
4848
needs: prep-testbed
49+
environment: ci_test
4950
strategy:
5051
fail-fast: false
5152
matrix:
@@ -56,7 +57,7 @@ jobs:
5657
test-path: ${{fromJson(needs.prep-testbed.outputs.matrix)}}
5758
runs-on: ubuntu-latest
5859
steps:
59-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v3
6061

6162
- name: Setup Python 3.8 for integration-test-docker-environment
6263
uses: actions/setup-python@v2
@@ -72,11 +73,15 @@ jobs:
7273

7374
- name: Run all tests
7475
run: ./scripts/test/run_test.sh ${{ matrix.test-path }}
76+
env: # Set the secret as an input
77+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
78+
DOCKER_PASSWD: ${{ secrets.DOCKER_PASSWD }}
79+
7580
upload:
7681
needs: test-all
7782
runs-on: ubuntu-latest
7883
steps:
79-
- uses: actions/checkout@v2
84+
- uses: actions/checkout@v3
8085

8186
- name: Setup Python 3.8
8287
uses: actions/setup-python@v2

.github/workflows/shellcheck.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ jobs:
66
shellcheck:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- name: Run shellcheck
1111
run: ./scripts/build/shellcheck.sh

doc/changes/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changes
22

3+
* [0.14.0](changes_0.14.0.md)
34
* [0.13.0](changes_0.13.0.md)
45
* [0.12.0](changes_0.12.0.md)
56
* [0.11.0](changes_0.11.0.md)

doc/changes/changes_0.14.0.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Script-Languages-Container-Tool 0.14.0, released 2022-05-25
2+
3+
Code name: Provide docker credentials to tests.
4+
5+
## Summary
6+
7+
This release contains a bugfix which avoids that tests exceed the Dockerhub pull rate limit and fail.
8+
9+
## Features / Enhancements
10+
11+
n/a
12+
13+
## Refactorings
14+
15+
n/a
16+
17+
## Bug Fixes
18+
19+
- #157: Injected docker credentials to test as environment variables
20+
21+
## Documentation
22+
23+
n/a

exasol_script_languages_container_tool/lib/tasks/test/run_db_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
from collections import namedtuple
12
from pathlib import Path
3+
from typing import Tuple, Optional
24

35
import luigi
6+
from exasol_integration_test_docker_environment.lib.config.docker_config import source_docker_repository_config, \
7+
target_docker_repository_config
8+
49
from exasol_script_languages_container_tool.lib.tasks.test.run_db_test_result import RunDBTestResult
510
from exasol_script_languages_container_tool.lib.tasks.test.run_db_tests_parameter import RunDBTestParameter
611
from exasol_integration_test_docker_environment.lib.base.flavor_task import FlavorBaseTask
@@ -60,11 +65,28 @@ def handle_test_result(self, bash_cmd, environment, exit_code, output):
6065
JsonPickleTarget(self.get_output_path().joinpath("test_result.json")).write(result, 4)
6166
self.return_object(result)
6267

68+
@staticmethod
69+
def _get_docker_credentials() -> Optional[namedtuple]:
70+
docker_credentials = namedtuple("DockerCredentials", "username password")
71+
if source_docker_repository_config().username is not None and \
72+
source_docker_repository_config().password is not None:
73+
return docker_credentials(source_docker_repository_config().username,
74+
source_docker_repository_config().password)
75+
if target_docker_repository_config().username is not None and \
76+
target_docker_repository_config().password is not None:
77+
return docker_credentials(target_docker_repository_config().username,
78+
target_docker_repository_config().password)
79+
return None
80+
6381
def run_test_command(self, bash_cmd, test_container):
6482
still_running_logger = StillRunningLogger(self.logger, "db tests")
6583
thread = StillRunningLoggerThread(still_running_logger)
6684
thread.start()
6785
environment = FrozenDictToDict().convert(self.test_environment_vars)
86+
docker_credentials = self.__class__._get_docker_credentials()
87+
if docker_credentials is not None:
88+
environment["DOCKER_USERNAME"] = docker_credentials.username
89+
environment["DOCKER_PASSWORD"] = docker_credentials.password
6890
environment["TEST_ENVIRONMENT_TYPE"] = self.test_environment_info.type.name
6991
environment["TEST_ENVIRONMENT_NAME"] = self.test_environment_info.name
7092
environment["TEST_DOCKER_NETWORK_NAME"] = self.test_environment_info.network_info.network_name

0 commit comments

Comments
 (0)