mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-09-26 08:53:15 +00:00
ci: test before publishing docker image (#390)
This commit is contained in:
parent
71e035c34c
commit
e1a8db51ad
97
.github/workflows/docker-publish.yml
vendored
97
.github/workflows/docker-publish.yml
vendored
@ -11,36 +11,83 @@ env:
|
|||||||
IMAGE_PLATFORMS: linux/amd64
|
IMAGE_PLATFORMS: linux/amd64
|
||||||
PACKAGE: "unstructured"
|
PACKAGE: "unstructured"
|
||||||
PIP_VERSION: "22.2.1"
|
PIP_VERSION: "22.2.1"
|
||||||
BUILD_TYPE_TAG_SUFFIX: ""
|
PYTHON_VERSION: "3.8"
|
||||||
|
NLTK_DATA: ${{ github.workspace }}/nltk_data
|
||||||
|
TEST_IMAGE_NAME: "unstructured-dev"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v3
|
- uses: actions/cache@v3
|
||||||
|
id: virtualenv-cache
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
.venv
|
||||||
|
nltk_data
|
||||||
|
key: unstructured-${{ runner.os }}-${{ hashFiles('requirements/*.txt') }}
|
||||||
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
- name: Setup virtual environment (no cache hit)
|
||||||
|
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
python${{ env.PYTHON_VERSION }} -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
make install-ci
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [setup]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set virtualenv cache
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: actions/cache@v3
|
||||||
|
id: virtualenv-cache
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
.venv
|
||||||
|
nltk_data
|
||||||
|
key: unstructured-${{ runner.os }}-${{ hashFiles('requirements/*.txt') }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up QEMU
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
- name: Login to Quay.io
|
- name: Set up Docker Buildx
|
||||||
uses: docker/login-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
|
||||||
registry: quay.io
|
|
||||||
username: ${{ secrets.QUAY_IO_ROBOT_USERNAME }}
|
|
||||||
password: ${{ secrets.QUAY_IO_ROBOT_TOKEN }}
|
|
||||||
|
|
||||||
# TODO(rniko): add a step to test the built image before pushing. Will add after https://unstructured-ai.atlassian.net/browse/CORE-745 is done
|
- name: Login to Quay.io
|
||||||
- name: Build and push Docker image
|
uses: docker/login-action@v1
|
||||||
run: |
|
with:
|
||||||
VERSION=$(grep -Po '(?<=__version__ = ")[^"]*' unstructured/__version__.py)
|
registry: quay.io
|
||||||
GIT_SHA=$(git rev-parse --short HEAD)
|
username: ${{ secrets.QUAY_IO_ROBOT_USERNAME }}
|
||||||
IMAGE_NAME=${{ env.PACKAGE }}
|
password: ${{ secrets.QUAY_IO_ROBOT_TOKEN }}
|
||||||
docker buildx build --platform=${{ env.IMAGE_PLATFORMS }} --provenance=false --push \
|
|
||||||
--build-arg PIP_VERSION=${{ env.PIP_VERSION }} \
|
- name: Build and push Docker image
|
||||||
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${GIT_SHA} \
|
run: |
|
||||||
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${VERSION} \
|
VERSION=$(grep -Po '(?<=__version__ = ")[^"]*' unstructured/__version__.py)
|
||||||
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:latest .
|
GIT_SHA=$(git rev-parse --short HEAD)
|
||||||
|
IMAGE_NAME=${{ env.PACKAGE }}
|
||||||
|
docker buildx create --use --driver=docker-container
|
||||||
|
docker buildx build --platform=${{ env.IMAGE_PLATFORMS }} --provenance=false --load \
|
||||||
|
--cache-to type=gha,scope=$GITHUB_REF_NAME-$IMAGE_NAME \
|
||||||
|
--cache-from type=gha,scope=$GITHUB_REF_NAME-$IMAGE_NAME \
|
||||||
|
--build-arg PIP_VERSION=${{ env.PIP_VERSION }} \
|
||||||
|
--progress plain \
|
||||||
|
-t ${{ env.TEST_IMAGE_NAME }}:latest \
|
||||||
|
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${GIT_SHA} \
|
||||||
|
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${VERSION} \
|
||||||
|
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:latest .
|
||||||
|
|
||||||
|
- name: Test image
|
||||||
|
run: |
|
||||||
|
source .venv/bin/activate
|
||||||
|
make docker-test
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
run: |
|
||||||
|
docker image push --all-tags ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${{ env.PACKAGE }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user