From f1648b293664e3bea50736280a19b846d60841f1 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 3 Jan 2022 23:42:14 +0100 Subject: [PATCH] CI: dockers & triggers --- .github/workflows/ci_pkg-install.yml | 4 +- .github/workflows/ci_testing.yml | 16 +++----- .github/workflows/docker-builds.yml | 10 ++--- .github/workflows/docs-check.yml | 4 +- .pre-commit-config.yaml | 7 +++- bm_experiments/Dockerfile | 57 ++++++++++++---------------- 6 files changed, 45 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci_pkg-install.yml b/.github/workflows/ci_pkg-install.yml index 35a6878..038c134 100644 --- a/.github/workflows/ci_pkg-install.yml +++ b/.github/workflows/ci_pkg-install.yml @@ -2,9 +2,9 @@ name: Install package # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the master branch - push: + push: {} + pull_request: branches: [master] - pull_request: {} jobs: pkg-check: diff --git a/.github/workflows/ci_testing.yml b/.github/workflows/ci_testing.yml index a0d83fc..b82a331 100644 --- a/.github/workflows/ci_testing.yml +++ b/.github/workflows/ci_testing.yml @@ -2,13 +2,13 @@ name: CI testing # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the master branch - push: + push: {} + pull_request: branches: [master] - pull_request: {} jobs: - pytest: + pytest: runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -17,12 +17,8 @@ jobs: python-version: [3.6, 3.9] requires: ['latest'] include: - - os: "ubuntu-18.04" - python-version: 2.7 - requires: 'latest' - - os: "ubuntu-18.04" - python-version: 3.6 - requires: 'minimal' + - {os: "ubuntu-18.04", python-version: 2.7, requires: 'latest'} + - {os: "ubuntu-18.04", python-version: 3.6, requires: 'oldest'} # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 35 @@ -51,7 +47,7 @@ jobs: pip install -U backports.functools_lru_cache - name: Set min. dependencies - if: matrix.requires == 'minimal' + if: matrix.requires == 'oldest' run: | for fpath in ('requirements.txt', 'tests/requirements.txt'): req = open(fpath).read().replace('>=', '==') diff --git a/.github/workflows/docker-builds.yml b/.github/workflows/docker-builds.yml index 6c818be..82aa962 100644 --- a/.github/workflows/docker-builds.yml +++ b/.github/workflows/docker-builds.yml @@ -2,8 +2,7 @@ name: Publish Docker Image # https://www.docker.com/blog/first-docker-github-action-is-here # https://github.com/docker/build-push-action on: # Trigger the workflow on push or pull request, but only for the master branch - push: - branches: [master] + push: {} pull_request: branches: [master] types: [opened, reopened, ready_for_review, synchronize] @@ -14,8 +13,9 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: - python_version: [3.7, 3.8, 3.9] + python_version: ["3.7", "3.8", "3.9"] steps: - name: Checkout uses: actions/checkout@v2 @@ -23,13 +23,13 @@ jobs: # Set up Docker Buildx - to use cache-from and cache-to argument of buildx command - uses: docker/setup-buildx-action@v1 - name: Login to DockerHub + if: ${{ github.repository_owner == 'Borda' }} uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and Publish to Docker Hub - # publish master uses: docker/build-push-action@v2 # https://github.com/docker/build-push-action#cache-to-registry with: @@ -38,6 +38,6 @@ jobs: cache-from: type=registry,ref=borda/birl:SOTA-py${{ matrix.python_version }} cache-to: type=inline file: bm_experiments/Dockerfile - push: ${{ github.ref == 'refs/heads/master' }} + push: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} tags: borda/birl:SOTA-py${{ matrix.python_version }} timeout-minutes: 240 diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 3bbad03..26525ce 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -3,9 +3,9 @@ name: "Docs check" # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the master branch - push: + push: {} + pull_request: branches: [master] - pull_request: {} jobs: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa1d6f7..609f777 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,8 +13,13 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + - id: check-case-conflict - id: check-yaml - - id: pretty-format-json + - id: check-toml + - id: check-json + - id: check-added-large-files + - id: check-docstring-first + - id: detect-private-key #- repo: https://github.com/pre-commit/mirrors-autopep8 # rev: v1.5.7 diff --git a/bm_experiments/Dockerfile b/bm_experiments/Dockerfile index a591316..fd5bc65 100644 --- a/bm_experiments/Dockerfile +++ b/bm_experiments/Dockerfile @@ -10,10 +10,10 @@ SHELL ["/bin/bash", "-c"] # for installing tzdata see: https://stackoverflow.com/a/58264927/4521646 ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && \ +RUN apt-get update -qq --fix-missing && \ apt-get install -y --no-install-recommends software-properties-common && \ add-apt-repository ppa:deadsnakes/ppa && \ - apt-get update && \ + apt-get update -qq --fix-missing && \ apt-get install -y --no-install-recommends \ python${PYTHON_VERSION} \ python${PYTHON_VERSION}-dev \ @@ -45,31 +45,9 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN \ - # BIRL requirement - apt-get update && \ - apt-get install -y --no-install-recommends \ - openslide-tools \ - && \ - -# Download BIRL from master - wget https://github.com/Borda/BIRL/archive/master.zip --progress=bar:force:noscroll && \ - unzip -q master.zip && \ - rm master.zip && \ - mv BIRL-master BIRL && \ - -# Install BIRL - # v46 crashes openslide-python install - pip install "setuptools<46" -U && \ - pip install ./BIRL --no-cache-dir && \ - python -c "import birl ; print(birl.__version__)" && \ - mkdir BIRL/Applications && \ -# Cleaning - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - ENV BIRL_APPs_PATH="/BIRL/Applications" +RUN mkdir -p $BIRL_APPs_PATH RUN \ cd $BIRL_APPs_PATH && \ @@ -84,7 +62,7 @@ RUN \ ENV ANTs_VERSION="2.3.4" RUN \ - apt-get update && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ zlib1g-dev \ && \ @@ -127,7 +105,7 @@ RUN \ ENV ANTSPY_VERSION="0.2.5" RUN \ - apt-get update && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ libopenblas-dev \ liblapack-dev \ @@ -163,8 +141,7 @@ RUN \ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BIRL_APPs_PATH/elastix/lib/" RUN \ -# add required libs - apt-get update && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ libtbb-dev \ libboost-all-dev \ @@ -228,8 +205,7 @@ RUN \ $BIRL_APPs_PATH/DROP2/dropreg --help RUN \ -# add required libs - apt-get update && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ r-base-core \ r-base-dev \ @@ -258,10 +234,25 @@ RUN \ # try to run RNiftyReg R -e 'library(RNiftyReg)' +COPY ./ /BIRL/ + +RUN \ + apt-get update -qq && \ + apt-get install -y --no-install-recommends \ + openslide-tools \ + && \ +# Install BIRL + # v46 crashes openslide-python install + pip install "setuptools<46" -U && \ + pip install ./BIRL --no-cache-dir && \ + python -c "import birl ; print(birl.__version__)" && \ +# Cleaning + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + RUN \ -# show installed applications - apt-get update && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ tree \ && \