Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
with:
persist-credentials: false
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.8'
- run: mkdir $GITHUB_WORKSPACE/package/lambda
- name: Install dependencies
run: |
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and push Docker images

on:
push:
branches: [ master ]
branches: [ master, feat/download-report ]
#pull_request:
# branches: [ master ]
workflow_dispatch:
Expand Down Expand Up @@ -34,8 +34,18 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set image tag
id: tag
run: |
if [ "${{ github.ref_name }}" = "master" ]; then
echo "value=getcarrier/control_tower:latest" >> $GITHUB_OUTPUT
else
SAFE=$(echo "${{ github.ref_name }}" | tr '/' '-')
echo "value=getcarrier/control_tower:${SAFE}" >> $GITHUB_OUTPUT
fi

- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ inputs.docker_tag || 'getcarrier/control_tower:latest' }}
tags: ${{ inputs.docker_tag || steps.tag.outputs.value }}
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: '3.8.5'
architecture: 'x64'
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 2 additions & 0 deletions control_tower/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
}

CONTAINER_TAG = 'latest'

DOWNLOAD_REPORT = environ.get("DOWNLOAD_REPORT", "").lower() in ("true", "yes", "1", "t")
411 changes: 383 additions & 28 deletions control_tower/run.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dulwich>=0.21.5
paramiko>=2.7.2
boto3>=1.27.0
mock>=4.0.3
git+https://github.com/carrier-io/arbiter.git@v.2.5
git+https://github.com/carrier-io/arbiter.git@v.2.5
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# conftest.py — project-wide pytest fixtures
#
# centry_loki (provided by loki_logger) is a runtime dependency that ships
# inside the Docker image via a GitHub install. It is NOT installed in the CI
# virtualenv because its PyPI package (loki-logger 1.1.1) requires
# requests>=2.31.0, which conflicts with arbiter==1.0.0 pinning
# requests==2.25.0.
#
# Tests never exercise Loki logging — they mock requests through
# requests_mock. Installing the real package just to satisfy the bare import
# at the top of run.py would break the pip dependency graph.
#
# Solution: install a sys.modules stub before any test file imports
# control_tower.run so the module-level `from centry_loki import log_loki`
# resolves to a MagicMock instead of raising ImportError.

import sys
from unittest import mock

# Register the stub before any test module imports control_tower.run
if "centry_loki" not in sys.modules:
centry_loki_stub = mock.MagicMock()
# make `from centry_loki import log_loki` work
centry_loki_stub.log_loki = mock.MagicMock()
sys.modules["centry_loki"] = centry_loki_stub
15 changes: 9 additions & 6 deletions tests/test_csv_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
token = "test"
project_id = 1
bucket = 'test'
csv_path = "age.csv"
# csv_files must be a dict: {csv_path: has_header}
csv_files = {"age.csv": True}
lg_count = 5


def test_split_csv():
with requests_mock.Mocker() as mock:
mock.get(f'{galloper_url}/api/v1/artifact/{project_id}/{bucket}/{artifact}',
mock.get(f'{galloper_url}/api/v1/artifacts/artifact/{project_id}/{bucket}/{artifact}',
content=open('tests/test.zip', "rb").read(), status_code=200)
mock.post(f'{galloper_url}/api/v1/artifact/{project_id}/{bucket}',
mock.post(f'{galloper_url}/api/v1/artifacts/artifacts/{project_id}/{bucket}',
json={"status": "mocked"}, status_code=200)
process_csv(galloper_url, token, project_id, artifact, bucket, csv_path, lg_count)
mock.post(f'{galloper_url}/api/v1/artifacts/artifacts/{project_id}/tests',
json={"status": "mocked"}, status_code=200)
process_csv(galloper_url, token, project_id, artifact, bucket, csv_files, lg_count, s3_settings={})
assert path.exists("/tmp/file_data/age.csv")
for i in [1, 2, 3, 4, 5]:
assert path.exists(f"/tmp/scv_files/age_{i}.csv")
assert len(open(f"/tmp/scv_files/age_{i}.csv", "r").readlines()) == 20
assert path.exists(f"/tmp/csv_files/age_{i}.csv")
assert len(open(f"/tmp/csv_files/age_{i}.csv", "r").readlines()) == 20
Loading
Loading