Skip to content

Commit

Permalink
Merge pull request #67 from paulsengroup/update-ci
Browse files Browse the repository at this point in the history
Update build-dockerfile workflow to test image after build
  • Loading branch information
robomics authored Sep 28, 2023
2 parents c969111 + ed41c0e commit 0ef9d13
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 31 deletions.
62 changes: 31 additions & 31 deletions .github/workflows/build-dockerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ jobs:
with:
platforms: arm64

- name: Build Docker image and push to registries
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}
push: ${{ github.event_name != 'pull_request' }}
load: true
push: false
cache-from: type=gha,scope=build-dockerfile
cache-to: type=gha,mode=min,scope=build-dockerfile
tags: ${{ steps.meta.outputs.tags }}
tags: hictk:test
platforms: ${{ steps.build-args.outputs.PLATFORMS }}
build-args: |
C_COMPILER=${{ steps.build-args.outputs.C_COMPILER }}
Expand All @@ -173,33 +174,35 @@ jobs:
GIT_IS_DIRTY=false
VERSION=${{ steps.build-args.outputs.VERSION }}
test-docker-image:
name: Test Docker image
needs: build-dockerfile
runs-on: ubuntu-latest
permissions:
packages: 'read'

if: github.event_name != 'pull_request'

container:
image: ghcr.io/${{ github.repository }}:latest
options: '--entrypoint /bin/bash'
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}

steps:
- name: Test hictk
- name: Test Docker image
run: |
set -o pipefail
utils/devel/test_docker_image.sh hictk:test
whereis -b hictk
ls -lah "$(whereis -b hictk | cut -d$' ' -f 2)"
- name: Push image to registries
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}
push: true
cache-from: type=gha,scope=build-dockerfile
cache-to: type=gha,mode=min,scope=build-dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ steps.build-args.outputs.PLATFORMS }}
build-args: |
C_COMPILER=${{ steps.build-args.outputs.C_COMPILER }}
CXX_COMPILER=${{ steps.build-args.outputs.CXX_COMPILER }}
BUILD_BASE_IMAGE=${{ steps.build-args.outputs.BUILD_BASE_IMAGE }}
TEST_BASE_IMAGE=${{ steps.build-args.outputs.TEST_BASE_IMAGE }}
FINAL_BASE_IMAGE=${{ steps.build-args.outputs.FINAL_BASE_IMAGE }}
FINAL_BASE_IMAGE_TAG=${{ steps.build-args.outputs.FINAL_BASE_IMAGE_TAG }}
FINAL_BASE_IMAGE_DIGEST=${{ steps.build-args.outputs.FINAL_BASE_IMAGE_DIGEST }}
GIT_HASH=${{ steps.build-args.outputs.GIT_HASH }}
GIT_SHORT_HASH=${{ steps.build-args.outputs.GIT_SHORT_HASH }}
CREATION_DATE=${{ steps.build-args.outputs.CREATION_DATE }}
GIT_TAG=${{ steps.build-args.outputs.GIT_TAG }}
GIT_IS_DIRTY=false
VERSION=${{ steps.build-args.outputs.VERSION }}
hictk --help
hictk --version
build-dockerfile-status-check:
Expand All @@ -208,12 +211,9 @@ jobs:
runs-on: ubuntu-latest
needs:
- build-dockerfile
- test-docker-image

steps:
- name: Collect job results
if: |
needs.build-dockerfile.result != 'success' ||
(needs.test-docker-image.result != 'success' &&
needs.test-docker-image.result != 'skipped')
needs.build-dockerfile.result != 'success'
run: exit 1
53 changes: 53 additions & 0 deletions utils/devel/test_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# Copyright (c) 2023 Roberto Rossini <roberros@uio.no>
#
# SPDX-License-Identifier: MIT

set -eu
set -o pipefail

if [ $# -ne 1 ]; then
2>&1 echo "Usage: $0 hictk:latest"
status=1
fi

IMG="$1"

tmpdir="$(mktemp -d)"
trap "rm -rf '$tmpdir'" EXIT

cat > "$tmpdir/runme.sh" <<- 'EOM'
set -eu
cd /tmp/hictk
apt-get update
apt-get install -y --no-install-recommends \
curl \
python3 \
xz-utils
tar -xf test/data/hictk_test_data.tar.xz
tmpdir="$(mktemp -d)"
trap "rm -rf '$tmpdir'" EXIT
hic_tools_url='https://github.com/aidenlab/HiCTools/releases/download/v3.30.00/hic_tools.3.30.00.jar'
curl -L "$hic_tools_url" -o "$tmpdir/hic_tools.jar"
whereis -b hictk
test/scripts/hictk_convert_hic2cool.sh "$(which hictk)"
test/scripts/hictk_convert_cool2hic.sh "$(which hictk)" "$tmpdir/hic_tools.jar"
EOM

chmod 755 "$tmpdir/runme.sh"

sudo docker run --rm --entrypoint=/bin/bash \
-v "$tmpdir/runme.sh:/tmp/runme.sh:ro" \
-v "$PWD/test/scripts:/tmp/hictk/test/scripts:ro" \
-v "$PWD/test/data/hictk_test_data.tar.xz:/tmp/hictk/test/data/hictk_test_data.tar.xz:ro" \
"$IMG" \
/tmp/runme.sh

0 comments on commit 0ef9d13

Please sign in to comment.