Skip to content

docker try #4

docker try #4 #62

Workflow file for this run

name: Push
on:
push:
workflow_dispatch:
pull_request:
env:
BUILDX_CACHE: /tmp/.buildx-cache
CACHE_KEY: gutils-buildx-
jobs:
pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9"]
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- name: Setup Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: false
- name: Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge
micromamba activate TEST
pip install -e . --no-deps --force-reinstall
- name: Debug conda
shell: bash -l {0}
run: |
micromamba activate TEST
micromamba info --all
micromamba list
- name: Tests
shell: bash -l {0}
run: |
micromamba activate TEST
pytest --disable-warnings -m "not long and not watch"
pypi-build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
shell: bash
- name: Install build tools
run: |
python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine
shell: bash
- name: Build binary wheel
run: python -m build --sdist --wheel . --outdir dist
- name: CheckFiles
run: |
ls dist
shell: bash
- name: Test wheels
run: |
cd dist && python -m pip install gutils*.whl
python -m twine check *
shell: bash
docker-build:
name: Build and test Docker Image
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
continue-on-error: true
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: false
tags: axiom/gutils:latest
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
outputs: type=docker
- name: Run tests from the Docker image
run: docker run axiom/gutils:latest pytest -m "not long"
docker-push:
name: Push latest image to Docker Hub
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: docker-build
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && github.repository == 'SECOORA/GUTILS'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push latest image to Docker Hub if on master or main branch of the repo
uses: docker/build-push-action@v2
with:
push: true
tags: axiom/gutils:latest
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }