Skip to content

Commit

Permalink
bug fix in CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Jan 22, 2024
1 parent 5a7abd4 commit 0e3d94d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 59 deletions.
85 changes: 27 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# - on push and PR: run pytest
# - on push to main: build and push container images as ":latest"
# - on push to semver tag: build and push container image with tag and
# - on push to server tag: build and push container image with tag and
# upload plugin description to https://chrisstore.co

name: build
Expand All @@ -12,7 +12,7 @@ on:
push:
branches: [ main ]
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ main ]

Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand All @@ -48,15 +48,19 @@ jobs:
build:
name: Build
if: github.event_name == 'push' || github.event_name == 'release'
# needs: [ test ] # uncomment to require passing tests
runs-on: ubuntu-22.04
# A local registry helps us reuse the built image between steps
services:
registry:
image: registry:2
ports:
- 5000:5000

steps:
- name: Get git tag
id: git_info
if: startsWith(github.ref, 'refs/tags/')
run: echo "tag=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Get project info
id: determine
env:
Expand All @@ -73,8 +77,8 @@ jobs:
dock_image=$repo:$tag
echo $dock_image
echo "dock_image=$dock_image" >> $GITHUB_OUTPUT
echo "repo=$repo" >> $GITHUB_OUTPUT
echo "::set-output name=dock_image::$dock_image"
echo "::set-output name=repo::$repo"
- uses: actions/checkout@v3
# QEMU is used for non-x86_64 builds
Expand All @@ -85,57 +89,13 @@ jobs:
driver-opts: network=host
# cache slightly improves rebuild time
- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Here, we want to do the docker build twice:
# The first build pushes to our local registry for testing.
# The second build pushes to Docker Hub and ghcr.io
- name: Build (local only)
uses: docker/build-push-action@v3
id: docker_build
with:
context: .
file: ./Dockerfile
tags: localhost/${{ steps.determine.outputs.dock_image }}
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
# If you have a directory called examples/incoming/ and examples/outgoing/, then
# run your ChRIS plugin with no parameters, and asser that it creates all the files
# which are expected. File contents are not compared.
- name: Run examples
id: run_examples
run: |
if ! [ -d 'examples/incoming/' ] || ! [ -d 'examples/outgoing/' ]; then
echo "No examples."
exit 0
fi
dock_image=localhost/${{ steps.determine.outputs.dock_image }}
output_dir=$(mktemp -d)
cmd=$(docker image inspect -f '{{ (index .Config.Cmd 0) }}' $dock_image)
docker run --rm -u "$(id -u):$(id -g)" \
-v "$PWD/examples/incoming:/incoming:ro" \
-v "$output_dir:/outgoing:rw" \
$dock_image $cmd /incoming /outgoing
for expected_file in $(find examples/outgoing -type f); do
fname="${expected_file##*/}"
out_path="$output_dir/$fname"
printf "Checking output %s exists..." "$out_path"
if [ -f "$out_path" ]; then
echo "ok"
else
echo "not found"
exit 1
fi
done
- name: Login to DockerHub
id: dockerhub_login
uses: docker/login-action@v2
Expand All @@ -149,13 +109,15 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
if: github.event_name == 'push' || github.event_name == 'release'
id: docker_build
with:
context: .
file: ./Dockerfile
tags: |
localhost:5000/${{ steps.determine.outputs.dock_image }}
docker.io/${{ steps.determine.outputs.dock_image }}
ghcr.io/${{ steps.determine.outputs.dock_image }}
# if non-x86_84 architectures are supported, add them here
Expand All @@ -169,16 +131,23 @@ jobs:
run: |
repo=${{ steps.determine.outputs.repo }}
dock_image=${{ steps.determine.outputs.dock_image }}
docker run --rm localhost/$dock_image chris_plugin_info > /tmp/description.json
docker run --rm localhost:5000/$dock_image chris_plugin_info > /tmp/description.json
jq < /tmp/description.json # pretty print in log
echo "title=$(jq -r '.title' < /tmp/description.json)" >> $GITHUB_OUTPUT
echo "::set-output name=title::$(jq -r '.title' < /tmp/description.json)"
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v3
uses: peter-evans/dockerhub-description@v2
continue-on-error: true # it is not crucial that this works
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ${{ steps.pluginmeta.outputs.title }}
readme-filepath: ./README.md
repository: ${{ steps.determine.outputs.repo }}
repository: ${{ steps.determine.outputs.repo }}

- name: Upload to ChRIS Store
if: steps.git_info.outcome != 'skipped'
uses: FNNDSC/chrisstore-action@master
with:
descriptor_file: /tmp/description.json
auth: ${{ secrets.CHRIS_STORE_USER }}
2 changes: 1 addition & 1 deletion dicom_dirSend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger.opt(colors = True)
logger.add(sys.stderr, format=logger_format)

__version__ = '1.0.5'
__version__ = '1.0.6'

DISPLAY_TITLE = r"""
_ _ _ _ _ _____ _
Expand Down

0 comments on commit 0e3d94d

Please sign in to comment.