diff --git a/.github/workflows/Docker-build-release.yaml b/.github/workflows/Docker-build-release.yaml index 6a9218e..e33a8f8 100644 --- a/.github/workflows/Docker-build-release.yaml +++ b/.github/workflows/Docker-build-release.yaml @@ -1,53 +1,33 @@ --- -name: Docker-build-release +name: Update image in GHCR + +run-name: > + ${{ + github.event_name == 'delete' && format( + 'Delete `{0}{1}`', + github.event.ref_type == 'branch' && 'branch-' || '', + github.event.ref + ) + || github.ref == 'refs/heads/main' && 'Update `dev`' + || format( + 'Update `{0}{1}`', + !startsWith(github.ref, 'refs/tags') && 'branch-' || '', + github.ref_name + ) + }} docker tag on: push: - branches: ['main'] + branches-ignore: ['gh-pages'] tags: ['v*'] - release: - types: [published] + delete: jobs: - build-and-push-image: + push-or-delete-image: runs-on: ubuntu-latest - name: A job to build and push a docker image + name: Update GitHub Container Registry permissions: contents: read packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Read YAML - id: yaml-data - uses: jbutcher5/read-yaml@1.6 - with: - file: metadata.yaml - key-path: '["image_name"]' - - - name: Create tags - id: meta - uses: docker/metadata-action@v3 - with: - flavor: | - latest=false - images: ghcr.io/uclahs-cds/${{ steps.yaml-data.outputs.data }} - tags: | - type=raw,enable=${{github.event_name == 'push'}},value=dev,event=branch - type=match,pattern=v(.*),group=1 - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ghcr.io/uclahs-cds - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - file: ./docker/Dockerfile + - uses: uclahs-cds/tool-Docker-action@v2 diff --git a/docker/Dockerfile b/Dockerfile similarity index 100% rename from docker/Dockerfile rename to Dockerfile diff --git a/pipeval/validate/validate.py b/pipeval/validate/validate.py index 52ffbbe..8481b53 100644 --- a/pipeval/validate/validate.py +++ b/pipeval/validate/validate.py @@ -63,11 +63,11 @@ def _validate_file( def _print_error(path:Path, err:BaseException): ''' Prints error message ''' - print(f'PID:{os.getpid()} - Error: `{str(path)}` {str(err)}') + print(f'PID:{os.getpid()} - Error: `{str(path)}` {str(err)}', file=sys.stderr) def _print_success(path:Path, file_type:str): ''' Prints success message ''' - print(f'PID:{os.getpid()} - Input: `{path}` is valid {file_type}') + print(f'PID:{os.getpid()} - Input: `{path}` is valid {file_type}', file=sys.stderr) def _detect_file_type_and_extension(path:Path): ''' File type and extension detection ''' @@ -98,7 +98,7 @@ def _validation_worker(path: Path, args:Union[ValidateArgs,Dict[str, Union[str,l file_type, file_extension = _detect_file_type_and_extension(path) _validate_file(path, file_type, file_extension, args) except FileNotFoundError as file_not_found_err: - print(f"Warning: {str(path)} {str(file_not_found_err)}") + print(f"Warning: {str(path)} {str(file_not_found_err)}", file=sys.stderr) except (TypeError, ValueError, IOError, OSError) as err: _print_error(path, err) return False diff --git a/pipeval/validate/validators/fastq.py b/pipeval/validate/validators/fastq.py index 041067d..ea23645 100644 --- a/pipeval/validate/validators/fastq.py +++ b/pipeval/validate/validators/fastq.py @@ -86,6 +86,7 @@ def _get_file_handler(self): '''Detect file format and return approriate handler to read file''' _handler_map = { 'application/x-gzip': gzip.open, + 'application/gzip': gzip.open, 'application/x-bzip2': bz2.open, 'text/plain': open } diff --git a/test/unit/test_validate.py b/test/unit/test_validate.py index 818843c..e237455 100644 --- a/test/unit/test_validate.py +++ b/test/unit/test_validate.py @@ -125,6 +125,7 @@ def test__check_compressed__raises_warning_for_uncompressed_path(mock_path, mock 'compression_mime', [ ('application/x-gzip'), + ('application/gzip'), ('application/x-bzip2') ] ) @@ -491,6 +492,7 @@ def test__validate_record__passes_valid_read(): 'test_file_type, test_handler', [ ('application/x-gzip', gzip.open), + ('application/gzip', gzip.open), ('application/x-bzip2', bz2.open), ('text/plain', open) ] @@ -580,6 +582,7 @@ def test__validate_fastq__passes_valid_fastq( 'test_file_type, test_handler', [ ('application/x-gzip', gzip.open), + ('application/gzip', gzip.open), ('application/x-bzip2', bz2.open), ('any/other', None) ]