Skip to content

Commit

Permalink
Merge eeca485 into a63e4c6
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Aug 1, 2021
2 parents a63e4c6 + eeca485 commit 7d17e1a
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 256 deletions.
2 changes: 1 addition & 1 deletion .azure/pipelines.yml
Expand Up @@ -49,7 +49,7 @@ jobs:
curl -sSkL https://www.stackage.org/stack/windows-x86_64 -o stack.zip
7z x stack.zip stack.exe -aoa
# Script for restoring source files modification time from commit to avoid recompilation.
curl -sSkL https://gist.githubusercontent.com/lehins/fd36a8cc8bf853173437b17f6b6426ad/raw/d9ddb32cac2f0dc6800be4fa54d450f0dcda6c60/git-modtime.hs -o git-modtime.hs
curl -sSkL https://raw.githubusercontent.com/lehins/utils/786c3fe7e9e1345d7b403019f52e344627224edf/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
# Restore mod time and setup ghc, if it wasn't restored from cache
./stack script --resolver ${RESOLVER} git-modtime.hs
- powershell: |
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
@@ -1,4 +1,4 @@
Please include this checklist whenever changes are introduced to either `massiv` or `massiv-io` packages:
Please include this checklist:

* [ ] Bump up the version in cabal file
* [ ] Any changes that could be relevant to users have been recorded in the `CHANGELOG.md`
Expand Down
129 changes: 129 additions & 0 deletions .github/workflows/haskell.yml
@@ -0,0 +1,129 @@
name: massiv-io-CI

on:
push:
branches: [ '*' ]
pull_request:
branches: [ master ]

defaults: { run: { shell: bash } }



jobs:
tests:
name: CI
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
resolver: [nightly, lts-18, lts-16, lts-14, lts-12]
include:
- resolver: lts-12
ghc: 8.4.4
stack-yaml: stack-extra-deps.yaml
- resolver: lts-14
stack-yaml: stack-extra-deps.yaml
- resolver: lts-16
ghc: 8.8.4
stack-yaml: stack-extra-deps.yaml
- resolver: lts-18
ghc: 8.10.4

# Latest stable for MacOS: ghc-8.8.4
- resolver: lts-16
os: macos-latest
stack-yaml: stack-extra-deps.yaml
# Latest stable for Windows: ghc-8.6.4
- resolver: lts-14
os: windows-latest
stack-yaml: stack-extra-deps.yaml

env:
STACK_YAML: stack.yaml
STACK_ARGS: '--resolver ${{ matrix.resolver }}'
cache-version: v1 # bump up this version to invalidate currently stored cache
steps:
- uses: actions/checkout@v2

- name: Cache
id: cache
uses: actions/cache@v2
if: matrix.os != 'macos-latest'
with:
path: |
~/.stack
.stack-work
massiv-io/.stack-work
key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
- name: Cache
id: cache-macos
uses: actions/cache@v2
if: matrix.os == 'macos-latest'
with:
path: |
~/.stack
key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
- name: Workaround setup-exe-cache failure on macos
if: steps.cache-macos.outputs.cache-hit == 'true' && matrix.os == 'macos-latest'
run: |
rm -r ~/.stack/setup-exe-cache
- name: Windows Cache
id: cache-windows
uses: actions/cache@v2
if: matrix.os == 'windows-latest'
with:
path: |
C:\\Users\\RUNNER~1\\AppData\\Roaming\\stack
C:\\Users\\RUNNER~1\\AppData\\Local\\Programs\\stack
key: ${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
- name: Ubuntu install GHC
if: matrix.ghc != '' && matrix.os == 'ubuntu-latest'
run: |
sudo add-apt-repository ppa:hvr/ghc -y
sudo apt-get update
sudo apt-get install ghc-${{ matrix.ghc }}
- name: Install Stack and local GHC
run: |
set -ex
curl -sSL https://get.haskellstack.org/ | sh -s - -f
curl -sSL https://raw.githubusercontent.com/lehins/utils/786c3fe7e9e1345d7b403019f52e344627224edf/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
stack $STACK_ARGS runghc git-modtime.hs
- name: Build
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
set -ex
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-14" ] && [ -n "${COVERALLS_TOKEN}" ]; then
stack $STACK_ARGS build massiv-io:tests --coverage --test --no-run-tests --haddock --no-haddock-deps
else
stack $STACK_ARGS build --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps
fi
- name: Tests
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
set -ex
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-14" ] && [ -n "${COVERALLS_TOKEN}" ]; then
stack $STACK_ARGS test massiv-io:tests --coverage --haddock --no-haddock-deps
stack $STACK_ARGS hpc report --all
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.6.1/shc-linux-x64-8.8.4.tar.bz2 | tar xj shc
./shc --repo-token="$COVERALLS_TOKEN" --partial-coverage --fetch-coverage combined custom
else
stack $STACK_ARGS test massiv-io:doctests
stack $STACK_ARGS test massiv-io:tests
fi
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions massiv-io/README.md
Expand Up @@ -5,9 +5,9 @@ in order to easily read, write and convert images in various formats and color s

## Status

| Language | Travis | Azure | Coveralls |Gitter.im |
|:--------:|:------:|:-----:|:---------:|:--------:|
| ![GitHub top language](https://img.shields.io/github/languages/top/lehins/massiv-io.svg) | [![Travis](https://img.shields.io/travis/lehins/massiv-io/master.svg?label=Linux%20%26%20OS%20X)](https://travis-ci.org/lehins/massiv-io) | [![Build Status](https://dev.azure.com/kuleshevich/massiv-io/_apis/build/status/lehins.massiv-io?branchName=master)](https://dev.azure.com/kuleshevich/massiv-io/_build?definitionId=1&branchName=master) | [![Coverage Status](https://coveralls.io/repos/github/lehins/massiv-io/badge.svg?branch=master)](https://coveralls.io/github/lehins/massiv-io?branch=master) | [![Join the chat at https://gitter.im/haskell-massiv/Lobby](https://badges.gitter.im/haskell-massiv/Lobby.svg)](https://gitter.im/haskell-massiv/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
| Language | Github Actions | Azure | Coveralls |Gitter.im |
|:--------:|:--------------:|:-----:|:---------:|:--------:|
| ![GitHub top language](https://img.shields.io/github/languages/top/lehins/massiv-io.svg) | [![Build Status](https://github.com/lehins/massiv/workflows/massiv-io-CI/badge.svg)](https://github.com/lehins/massiv-io/actions) | [![Build Status](https://dev.azure.com/kuleshevich/massiv-io/_apis/build/status/lehins.massiv-io?branchName=master)](https://dev.azure.com/kuleshevich/massiv-io/_build?definitionId=1&branchName=master) | [![Coverage Status](https://coveralls.io/repos/github/lehins/massiv-io/badge.svg?branch=master)](https://coveralls.io/github/lehins/massiv-io?branch=master) | [![Join the chat at https://gitter.im/haskell-massiv/Lobby](https://badges.gitter.im/haskell-massiv/Lobby.svg)](https://gitter.im/haskell-massiv/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

| Package | Hackage | Nightly | LTS |
|:-------------------|:-------:|:-------:|:---:|
Expand Down
5 changes: 3 additions & 2 deletions massiv-io/massiv-io.cabal
@@ -1,5 +1,5 @@
name: massiv-io
version: 0.4.1.0
version: 1.0.0.0
synopsis: Import/export of Image files into massiv Arrays
description: This package contains functionality for import/export of arrays
into the real world. For now it only has the ability to read/write
Expand Down Expand Up @@ -40,7 +40,7 @@ library
, deepseq
, exceptions
, filepath
, massiv >= 0.3
, massiv >= 1.0.0
, JuicyPixels >= 3.3.5
, netpbm
, unliftio >= 0.2.12
Expand All @@ -64,6 +64,7 @@ test-suite tests
, Test.Massiv.Array.IO.Image.JuicyPixelsSpec
, Test.Massiv.Array.IO.Image.AutoSpec
, Spec
build-tool-depends: hspec-discover:hspec-discover
build-depends: JuicyPixels
, QuickCheck
, base
Expand Down
16 changes: 6 additions & 10 deletions massiv-io/src/Data/Massiv/Array/IO.hs
Expand Up @@ -59,12 +59,10 @@ import Data.Massiv.Array.IO.Base as Base (Auto(..), ConvertError(..),
convertImage, coerceBinaryImage,
decode', decodeError,
defaultWriteOptions,
demoteLumaAlphaImage, demoteLumaImage,
encode', encodeError,
fromImageBaseModel, fromMaybeDecode,
fromMaybeEncode,
promoteLumaAlphaImage,
promoteLumaImage, toImageBaseModel,
toImageBaseModel,
toProxy)
import Data.Massiv.Array.IO.Image
import Graphics.Pixel.ColorSpace
Expand Down Expand Up @@ -208,7 +206,7 @@ readImage path = liftIO (B.readFile path >>= decodeImageM imageReadFormats path)
--
-- @since 0.1.0
readImageAuto ::
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadIO m)
(Mutable r (Pixel cs e), ColorSpace cs i e, MonadIO m)
=> FilePath -- ^ File path for an image
-> m (Image r cs e)
readImageAuto path = liftIO (B.readFile path >>= decodeImageM imageReadAutoFormats path)
Expand All @@ -228,7 +226,7 @@ readImageAuto path = liftIO (B.readFile path >>= decodeImageM imageReadAutoForma
--
-- @since 0.1.0
writeImage ::
(Source r Ix2 (Pixel cs e), ColorModel cs e, MonadIO m) => FilePath -> Image r cs e -> m ()
(Source r (Pixel cs e), ColorModel cs e, MonadIO m) => FilePath -> Image r cs e -> m ()
writeImage path img = liftIO (encodeImageM imageWriteFormats path img >>= writeLazyAtomically path)


Expand All @@ -245,15 +243,14 @@ writeImage path img = liftIO (encodeImageM imageWriteFormats path img >>= writeL
--
-- @since 0.1.0
writeImageAuto ::
(Source r Ix2 (Pixel cs e), ColorSpace cs i e, ColorSpace (BaseSpace cs) i e, MonadIO m)
(Source r (Pixel cs e), ColorSpace cs i e, ColorSpace (BaseSpace cs) i e, MonadIO m)
=> FilePath
-> Image r cs e
-> m ()
writeImageAuto path img =
liftIO (encodeImageM imageWriteAutoFormats path img >>= writeLazyAtomically path)



-- | An image is written as a @.tiff@ file into an operating system's temporary
-- directory and passed as an argument to the external viewer program.
--
Expand All @@ -265,8 +262,7 @@ displayImageUsing ::
-- closed. Supplying `False` is only safe in the ghci session.
-> Image r cs e -- ^ Image to display
-> m ()
displayImageUsing viewer block =
displayImageUsingAdhoc viewer block (writableAdhoc (Auto TIF))
displayImageUsing viewer block = displayImageUsingAdhoc viewer block (writableAdhoc (Auto TIF))


-- | Encode an image using an adhoc into an operating system's temporary
Expand Down Expand Up @@ -317,7 +313,7 @@ displayImageFile (ExternalViewer exe args ix) imgPath =
-- set as a default image viewer by the OS. This is a non-blocking function call, so it
-- might take some time before an image will appear.
--
-- /Note/ - This function should only be used in ghci, otherwise use @`displayImage`
-- /Note/ - This function should only be used in ghci, otherwise use @`displayImageUsing`
-- `defaultViewer` `True`@
--
-- @since 0.1.0
Expand Down

0 comments on commit 7d17e1a

Please sign in to comment.