[pre-commit.ci] pre-commit autoupdate #1528
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [master] | |
tags: [v*.*.*] | |
pull_request: | |
branches: [master] | |
pull_request_target: | |
branches: [master] | |
concurrency: CI | |
jobs: | |
build: | |
if: | | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') | |
strategy: | |
matrix: | |
base-image: | |
- nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 | |
- nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 | |
dockerfile: | |
- Dockerfile | |
- Dockerfile.minimal | |
env: | |
IMAGE_NAME: ghcr.io/neuro-inc/base | |
NEURO_CLUSTER: onprem-poc | |
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }} | |
NEURO_TOKEN: ${{ secrets.NEURO_TOKEN }} | |
BASE_IMAGE: ${{ matrix.base-image }} | |
name: Build, test and publish image | |
runs-on: ubuntu-latest | |
timeout-minutes: 150 | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
pip install -U neuro-cli | |
- name: Configure environment | |
run: | | |
source venv/bin/activate | |
neuro config login-with-token $NEURO_TOKEN $NEURO_STAGING_URL | |
neuro config switch-cluster $NEURO_CLUSTER | |
neuro config show | |
- name: Login ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get image tags | |
id: get-image-tags | |
run: | | |
if [[ ${{ matrix.base-image }} =~ runtime ]]; then | |
export BASE_IMAGE_TYPE="runtime"; | |
elif [[ ${{ matrix.base-image }} =~ devel ]]; then | |
export BASE_IMAGE_TYPE="devel"; | |
fi | |
if [[ ${{ matrix.dockerfile }} =~ minimal ]]; then | |
export BASE_IMAGE_TYPE="$BASE_IMAGE_TYPE-minimal"; | |
fi | |
echo "::set-output name=BASE_IMAGE_TYPE::$BASE_IMAGE_TYPE" | |
echo "::set-output name=platform_image_tag::ghcr.io/neuro-inc/base:built-$BASE_IMAGE_TYPE" | |
- name: Cleanup tool cache | |
run: | | |
du -h -d 1 /opt/hostedtoolcache | |
rm -rf /opt/hostedtoolcache/go /opt/hostedtoolcache/CodeQL | |
- name: Build image | |
env: | |
BASE_IMAGE_TYPE: ${{ steps.get-image-tags.outputs.BASE_IMAGE_TYPE }} | |
DOCKERFILE: ${{ matrix.dockerfile }} | |
run: | | |
make image_build | |
- name: List pip packages | |
run: | | |
docker run --tty --rm ${{ steps.get-image-tags.outputs.platform_image_tag }} pip list | |
- name: Test image | |
env: | |
BASE_IMAGE_TYPE: ${{ steps.get-image-tags.outputs.BASE_IMAGE_TYPE }} | |
TEST_PRESET: gpu-1x3090 | |
run: | | |
source venv/bin/activate | |
make e2e_neuro_push | |
if [[ ${{ matrix.dockerfile }} =~ minimal ]]; then | |
export TEST_CMD="bash /var/storage/dependencies.minimal.sh"; | |
fi | |
make test_dependencies | |
- name: Push release | |
env: | |
BASE_IMAGE_TYPE: ${{ steps.get-image-tags.outputs.BASE_IMAGE_TYPE }} | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
export TARGET_IMAGE_TAGS="latest-$BASE_IMAGE_TYPE,${GITHUB_REF#refs/tags/}-$BASE_IMAGE_TYPE"; | |
if [[ $BASE_IMAGE_TYPE == runtime ]]; then | |
export TARGET_IMAGE_TAGS="latest,$TARGET_IMAGE_TAGS"; | |
fi | |
make image_deploy | |
if [[ $BASE_IMAGE_TYPE == runtime ]]; then | |
# publish legacy images | |
TARGET_IMAGE_NAME="neuromation/base" | |
make image_deploy | |
fi |