Skip to content

Commit

Permalink
Run update-version-file in docker (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Sep 22, 2020
1 parent 2494c61 commit 15bfc20
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 25 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yaml
Expand Up @@ -28,12 +28,6 @@ jobs:
# - models-gpu-legacy
steps:
- uses: actions/checkout@v2
- name: Set up python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install automation scripts dependencies
run: pip install -r automation/requirements.txt
- name: Docker login
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ secrets.CR_USERNAME }} --password-stdin
- name: Set GIT_HASH env var
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci.yaml
Expand Up @@ -46,12 +46,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install automation scripts dependencies
run: pip install -r automation/requirements.txt
- name: Run Dockerized tests
run: make test-dockerized

Expand All @@ -60,12 +54,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install automation scripts dependencies
run: pip install -r automation/requirements.txt
- name: Generate HTML docs
run: make html-docs-dockerized
- name: Upload generated docs
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Expand Up @@ -64,9 +64,18 @@ endif
find . \( ! -regex '.*/\..*' \) -a \( -iname \*.md -o -iname \*.txt -o -iname \*.yaml -o -iname \*.yml \) \
-type f -print0 | xargs -0 sed -i '' -e 's/:$(MLRUN_OLD_VERSION_ESCAPED)/:$(MLRUN_NEW_VERSION)/g'

MLRUN_AUTOMATION_IMAGE_NAME := $(MLRUN_DOCKER_IMAGE_PREFIX)/automation:$(MLRUN_DOCKER_TAG)

.PHONY: automation
automation: ## Build automation docker image
docker build \
--file dockerfiles/automation/Dockerfile \
--build-arg MLRUN_PYTHON_VERSION=$(MLRUN_PYTHON_VERSION) \
--tag $(MLRUN_AUTOMATION_IMAGE_NAME) .

.PHONY: update-version-file
update-version-file: ## Update the version file
python ./automation/version/version_file.py create $(MLRUN_VERSION)
update-version-file: automation ## Update the version file
docker run -t --rm -e "MLRUN_VERSION=$(MLRUN_VERSION)" -v $(PWD):/mlrun $(MLRUN_AUTOMATION_IMAGE_NAME)

.PHONY: build
build: docker-images package-wheel ## Build all artifacts
Expand Down
8 changes: 4 additions & 4 deletions automation/version/version_file.py
Expand Up @@ -7,7 +7,8 @@
import logging

# not using mlrun.utils.logger to not require mlrun package
logger = logging.Logger(name="version", level="DEBUG")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("version_file")


@click.group()
Expand All @@ -22,6 +23,7 @@ def create(mlrun_version: str):
try:
out, _, _ = _run_command("git", args=["rev-parse", "HEAD"])
git_commit = out.strip()
logger.debug(f"Found git commit: {git_commit}")

except Exception as exc:
logger.warning("Failed to get version", exc_info=exc)
Expand All @@ -38,9 +40,7 @@ def create(mlrun_version: str):
json.dump(version_info, version_file, sort_keys=True, indent=2)


def _run_command(
command: str, args: list = None, suppress_errors: bool = False,
) -> (str, str, int):
def _run_command(command: str, args: list = None,) -> (str, str, int):
if args:
command += " " + " ".join(args)

Expand Down
32 changes: 32 additions & 0 deletions dockerfiles/automation/Dockerfile
@@ -0,0 +1,32 @@
# Copyright 2018 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG MLRUN_PYTHON_VERSION=3.7

FROM python:${MLRUN_PYTHON_VERSION}-slim

RUN apt-get update && apt-get install -y \
git-core

RUN python -m pip install --upgrade --no-cache pip

COPY ./automation/requirements.txt ./requirements.txt

RUN python -m pip install -r requirements.txt

WORKDIR /mlrun

VOLUME /mlrun

# "sh" is needed to enforce running in a shell - otherwise env vars substitution won't happen
CMD ["sh", "-c", "python ./automation/version/version_file.py create $MLRUN_VERSION"]
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -19,7 +19,8 @@
import json
import logging

logger = logging.Logger(name="mlrun-setup", level="INFO")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("mlrun-setup")


def version():
Expand Down

0 comments on commit 15bfc20

Please sign in to comment.