Skip to content

Commit

Permalink
[CI] Create a cache tag per version for the build images workflow (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Dec 19, 2020
1 parent 3192157 commit 28c7a4d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/build.yaml
Expand Up @@ -41,11 +41,18 @@ jobs:
- uses: actions/checkout@v2
- name: Install curl and jq
run: sudo apt-get install curl jq
- name: Extract git hashes and latest version
- name: Extract git hashes + branch and latest version
id: git_info
run: |
echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=mlrun_commit_hash::$(git rev-parse --short $GITHUB_SHA)"
echo "::set-output name=latest_version::$(curl -sf https://pypi.org/pypi/mlrun/json | jq -r '.info.version')"
- name: Resolve docker cache tag
id: docker_cache
run: |
export version_suffix=$(echo "${{ steps.git_info.outputs.branch }}" | grep -E "^[0-9]+\.[0-9]+\.x$" | tr -d '.')
export unstable_tag=$(if [ -z "$version_suffix" ]; then echo "unstable-cache"; else echo "unstable-cache-$version_suffix";fi)
echo "::set-output name=tag::$(echo $unstable_tag)"
- name: Set computed versions params
id: computed_params
run: |
Expand All @@ -70,13 +77,13 @@ jobs:
MLRUN_DOCKER_REGISTRY=${{ steps.computed_params.outputs.mlrun_docker_registry }} \
MLRUN_DOCKER_REPO=${{ steps.computed_params.outputs.mlrun_docker_repo }} \
MLRUN_VERSION=${{ steps.computed_params.outputs.mlrun_version }} \
MLRUN_DOCKER_CACHE_FROM_TAG=unstable-cache \
MLRUN_DOCKER_CACHE_FROM_TAG=${{ steps.docker_cache.outputs.tag }} \
make push-${{ matrix.image-name }}
- name: Pull cache, build and push test image
if: ${{ matrix.image-name == 'test' }}
run: |
MLRUN_DOCKER_REGISTRY=${{ steps.computed_params.outputs.mlrun_docker_registry }} \
MLRUN_DOCKER_REPO=${{ steps.computed_params.outputs.mlrun_docker_repo }} \
MLRUN_VERSION=unstable-cache \
MLRUN_DOCKER_CACHE_FROM_TAG=unstable-cache \
MLRUN_VERSION=${{ steps.docker_cache.outputs.tag }} \
MLRUN_DOCKER_CACHE_FROM_TAG=${{ steps.docker_cache.outputs.tag }} \
make push-${{ matrix.image-name }}
39 changes: 36 additions & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -43,24 +43,57 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# TODO: re-use the next 2 actions instead of duplicating
- name: Extract git branch
id: git_info
run: |
echo "::set-output name=branch::$(echo ${GITHUB_BASE_REF#refs/heads/})"
- name: Resolve docker cache tag
id: docker_cache
run: |
export version_suffix=$(echo "${{ steps.git_info.outputs.branch }}" | grep -E "^[0-9]+\.[0-9]+\.x$" | tr -d '.')
export unstable_tag=$(if [ -z "$version_suffix" ]; then echo "unstable-cache"; else echo "unstable-cache-$version_suffix";fi)
echo "::set-output name=tag::$(echo $unstable_tag)"
- name: Run Dockerized tests
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=unstable-cache make test-dockerized
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=${{ steps.docker_cache.outputs.tag }} make test-dockerized

migrations-tests:
name: Run Dockerized Migrations Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# TODO: re-use the next 2 actions instead of duplicating
- name: Extract git branch
id: git_info
run: |
echo "::set-output name=branch::$(echo ${GITHUB_BASE_REF#refs/heads/})"
- name: Resolve docker cache tag
id: docker_cache
run: |
export version_suffix=$(echo "${{ steps.git_info.outputs.branch }}" | grep -E "^[0-9]+\.[0-9]+\.x$" | tr -d '.')
export unstable_tag=$(if [ -z "$version_suffix" ]; then echo "unstable-cache"; else echo "unstable-cache-$version_suffix";fi)
echo "::set-output name=tag::$(echo $unstable_tag)"
- name: Run Dockerized DB Migration tests
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=unstable-cache make test-migrations-dockerized
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=${{ steps.docker_cache.outputs.tag }} make test-migrations-dockerized

docs:
name: Build Project Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# TODO: re-use the next 2 actions instead of duplicating
- name: Extract git branch
id: git_info
run: |
echo "::set-output name=branch::$(echo ${GITHUB_BASE_REF#refs/heads/})"
- name: Resolve docker cache tag
id: docker_cache
run: |
export version_suffix=$(echo "${{ steps.git_info.outputs.branch }}" | grep -E "^[0-9]+\.[0-9]+\.x$" | tr -d '.')
export unstable_tag=$(if [ -z "$version_suffix" ]; then echo "unstable-cache"; else echo "unstable-cache-$version_suffix";fi)
echo "::set-output name=tag::$(echo $unstable_tag)"
- name: Generate HTML docs
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=unstable-cache make html-docs-dockerized
run: MLRUN_DOCKER_REGISTRY=ghcr.io/ MLRUN_DOCKER_CACHE_FROM_TAG=${{ steps.docker_cache.outputs.tag }} make html-docs-dockerized
- name: Upload generated docs
uses: actions/upload-artifact@v2
with:
Expand Down

0 comments on commit 28c7a4d

Please sign in to comment.