Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Dockerfile.scheduler into 2 images: alts-scheduler and alts-tests #89

Merged
merged 1 commit into from
Apr 5, 2024
Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
uses: docker/build-push-action@v5
with:
file: Dockerfile.scheduler
target: alts-tests
context: .
load: true
cache-from: type=gha
Expand All @@ -74,7 +75,7 @@ jobs:

- name: Run pytest
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm --no-deps alts_tests bash -c "
/usr/sbin/sshd && \
pytest -v --cov \
--junit-xml=$REPORTS_DIR/pytest-report.xml \
Expand All @@ -84,28 +85,28 @@ jobs:
- name: Run pylint
if: ${{ steps.changed-files.outputs.src == 'true' }}
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm alts_tests bash -c "
pylint --exit-zero ${{ steps.changed-files.outputs.src_files }} \
| tee $REPORTS_DIR/pylint-report.txt"

- name: Run black
if: ${{ steps.changed-files.outputs.py == 'true' }}
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm alts_tests bash -c "
black --check --diff --color ${{ steps.changed-files.outputs.py_files }} \
| tee >(sed 's/\x1B\[[0-9;]*m//g' > $REPORTS_DIR/black-report.txt)"

- name: Run isort
if: ${{ steps.changed-files.outputs.py == 'true' }}
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm alts_tests bash -c "
isort --check-only --diff --color ${{ steps.changed-files.outputs.py_files }} \
| tee >(sed 's/\x1B\[[0-9;]*m//g' > $REPORTS_DIR/isort-report.txt)"

- name: Run bandit
if: ${{ steps.changed-files.outputs.src == 'true' }}
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm alts_tests bash -c "
bandit -c pyproject.toml ${{ steps.changed-files.outputs.src_files }} \
| tee >(sed 's/\x1B\[[0-9;]*m//g' > $REPORTS_DIR/bandit-report.txt)"

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
with:
file: Dockerfile.scheduler
context: .
target: alts-tests
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -39,7 +40,7 @@ jobs:
- name: Run pytest
id: pytest
run: |
docker compose run --rm --no-deps tests bash -c "
docker compose run --rm alts_tests bash -c "
/usr/sbin/sshd && \
pytest -v --cov \
--cov-report=json:$REPORTS_DIR/pytest-report.json \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.celery
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ EOT
RUN <<EOT
set -ex
python3 -m ensurepip
pip3 install -r celery.txt -r devel.txt
pip3 install -r celery.txt
EOT

RUN rm -f *.txt
14 changes: 12 additions & 2 deletions Dockerfile.scheduler
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM almalinux:9
FROM almalinux:9 as alts-scheduler

RUN <<EOT
set -ex
Expand All @@ -22,8 +22,18 @@ COPY requirements .
RUN <<EOT
set -ex
python3 -m ensurepip
pip3 install -r scheduler.txt -r devel.txt
pip3 install -r scheduler.txt
rm -f *.txt
EOT

ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /


FROM alts-scheduler as alts-tests

COPY requirements/tests.txt requirements-tests.txt
RUN <<EOT
set -ex
pip3 install -r requirements-tests.txt
rm requirements-tests.txt
EOT
11 changes: 9 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
image: alts-scheduler:latest
build:
dockerfile: Dockerfile.scheduler
target: alts-scheduler
context: .
environment:
CELERY_CONFIG_PATH: "/scheduler_config.yaml"
Expand All @@ -51,8 +52,14 @@ services:
depends_on:
- rabbitmq

tests:
extends: scheduler
alts_tests:
image: alts-tests:latest
build:
dockerfile: Dockerfile.scheduler
target: alts-tests
context: .
environment:
CELERY_CONFIG_PATH: "tests/tests_config.yaml"
SCHEDULER_CONFIG_PATH: "tests/tests_config.yaml"
volumes:
- ".:/code"
File renamed without changes.
Loading