Skip to content

updated

updated #5

Workflow file for this run

# modified from https://docs.docker.com/build/ci/github-actions/push-multi-registries/
name: build_docker
on:
workflow_dispatch:
push:
# todo2: disable again
branches:
- "main"
tags:
- 'v*' # push of any tag
# workflow_run:
# workflows: ["run_tox"]
# branches: [main]
# types:
# - completed
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: ${{ github.repository }}_test
BUILD_TARGET: dev # prod
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
jobs:
docker:
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }} # the special secrets.GITHUB_TOKEN only allows access to the current repository, so we added a personal access token with scope "repo" as a secret to this repo
submodules: true
-
# qemu required if building for multiple platforms with Docker (other than the platform the docker build is executed on)
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# -
# name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
# ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Build and export to Docker (using cache)
uses: docker/build-push-action@v4
timeout-minutes: 20
with:
context: .
target: ${{ env.BUILD_TARGET }}
load: true
tags: ${{ env.TEST_TAG }}
# todo2: disable cache eventually
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Test docker image in python3.10
uses: addnab/docker-run-action@v3
timeout-minutes: 20
with:
image: ${{ env.TEST_TAG }}
shell: /bin/bash
run: |
set -ex
source ~/ont_project_all/ont_project_venv/bin/activate || true
export PATH=~/ont_project_all/tools/bin:$PATH && which minimap2
cd /root/ont_project_all/ont_project
sed -i'.backup' -e "s@{root:uri}@file://$(pwd)@g" -e "s@[email protected]+dockerbuild$(date +%YY%mM%dD%HH%MM%SS)@" pyproject.toml
pip install tox
tox run -e py310
-
name: Push docker image
uses: docker/build-push-action@v4
timeout-minutes: 20
id: Push
with:
context: .
platforms: linux/amd64 #,linux/arm64
target: ${{ env.BUILD_TARGET }}
push: true
tags: ${{ steps.meta.outputs.tags }}_${{ env.BUILD_TARGET }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Run full usecase (in Docker container)
uses: addnab/docker-run-action@v3
timeout-minutes: 20
with:
image: ${{ env.TEST_TAG }}
shell: /bin/bash
run: |
set -ex
cd ~/ont_project_all/ont_project
curl https://public.bmi.inf.ethz.ch/user/mmordig/ont_project/prepackaged/usecase_data_docker.tar.gz -O
tar -xvzf usecase_data_docker.tar.gz
pwd
ls -lR .
cd runs/enrich_usecase
source ~/ont_project_all/ont_project_venv/bin/activate || true
export PATH=~/ont_project_all/tools/bin:$PATH && which minimap2
mkdir chr202122_run && cd chr202122_run
ln -s ../data .
ln -s ../configs/chr202122_run/sampler_per_window configs
python ~/ont_project_all/ont_project/usecases/enrich_usecase.py
tar -cvzf figures.tar.gz simulator_run/figures
-
name: Archive figures
uses: actions/upload-artifact@v3
timeout-minutes: 10
with:
name: usecase-figures
path: figures.tar.gz