Skip to content

Commit cf4ad51

Browse files
authored
Set up CI with Azure Pipelines (#16)
Set up CI with Azure Pipelines
1 parent 00a5a8a commit cf4ad51

7 files changed

Lines changed: 213 additions & 4 deletions

File tree

.azure/azure-linux-template.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
timeoutInMinutes: 120
4+
pool:
5+
vmImage: ${{ parameters.vmImage }}
6+
strategy:
7+
matrix:
8+
stack-def:
9+
BUILD: stack
10+
STACK_YAML: stack.yaml
11+
stack-lts-13:
12+
BUILD: stack
13+
STACK_YAML: stack-lts-13.yaml
14+
cabal-8.4.3:
15+
BUILD: cabal
16+
GHCVER: 8.4.3
17+
CABALVER: 2.4
18+
cabal-8.6.3:
19+
BUILD: cabal
20+
GHCVER: 8.6.3
21+
CABALVER: 2.4
22+
nightly:
23+
BUILD: stack
24+
ARGS: "--resolver nightly"
25+
style:
26+
BUILD: style
27+
pedantic:
28+
BUILD: pedantic
29+
STACK_YAML: stack.yaml
30+
maxParallel: 6
31+
steps:
32+
- script: |
33+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
34+
mkdir -p ~/.local/bin
35+
curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
36+
case "$BUILD" in
37+
style)
38+
PACKAGE=hlint
39+
echo "Downloading $PACKAGE now ..."
40+
41+
RELEASES=$(curl --silent https://github.com/ndmitchell/$PACKAGE/releases)
42+
URL=https://github.com/$(echo "$RELEASES" | grep -o '\"[^\"]*-x86_64-linux\.tar\.gz\"' | sed s/\"//g | head -n1)
43+
VERSION=$(echo "$URL" | sed -e 's/.*-\([\.0-9]\+\)-x86_64-linux\.tar\.gz/\1/')
44+
45+
curl --progress-bar --location -o"$PACKAGE.tar.gz" "$URL"
46+
tar -xzf "$PACKAGE.tar.gz" -C .
47+
mv "$PACKAGE-$VERSION" "$PACKAGE"
48+
export PATH="$(pwd)"/hlint:$PATH
49+
;;
50+
cabal)
51+
sudo add-apt-repository -y ppa:hvr/ghc
52+
sudo apt-get update
53+
sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
54+
# See note here: https://github.com/haskell-CI/haskell-ci#alex--happy-with-ghc--78
55+
if [ "$GHCVER" = "head" ] || [ "${GHCVER%.*}" = "7.8" ] || [ "${GHCVER%.*}" = "7.10" ]; then
56+
sudo apt-get install happy-1.19.4 alex-3.1.3
57+
export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH
58+
else
59+
sudo apt-get install happy alex
60+
fi
61+
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
62+
cabal --version
63+
cabal update
64+
PACKAGES=$(stack --install-ghc query locals | grep '^ *path' | sed 's@^ *path:@@')
65+
cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
66+
;;
67+
*)
68+
export PATH=$HOME/.local/bin:$PATH
69+
stack --install-ghc $ARGS test --bench --only-dependencies
70+
;;
71+
esac
72+
set -ex
73+
case "$BUILD" in
74+
style)
75+
hlint src/
76+
;;
77+
cabal)
78+
cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
79+
80+
ORIGDIR=$(pwd)
81+
for dir in $PACKAGES
82+
do
83+
cd $dir
84+
cabal check || [ "$CABALVER" == "1.16" ]
85+
cabal sdist
86+
PKGVER=$(cabal info . | awk '{print $2;exit}')
87+
SRC_TGZ=$PKGVER.tar.gz
88+
cd dist
89+
tar zxfv "$SRC_TGZ"
90+
cd "$PKGVER"
91+
cabal configure --enable-tests --ghc-options -O0
92+
cabal build
93+
if [ "$CABALVER" = "1.16" ] || [ "$CABALVER" = "1.18" ]; then
94+
cabal test
95+
else
96+
cabal test --show-details=streaming
97+
fi
98+
cd $ORIGDIR
99+
done
100+
;;
101+
*)
102+
stack $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
103+
;;
104+
esac
105+
set +ex
106+
env:
107+
OS_NAME: ${{ parameters.os }}
108+
displayName: 'Installation ${{parameters.os}} & Test'

.azure/azure-osx-template.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
pool:
4+
vmImage: ${{ parameters.vmImage }}
5+
strategy:
6+
matrix:
7+
stack-def:
8+
BUILD: stack
9+
STACK_YAML: stack.yaml
10+
stack-lts-13:
11+
BUILD: stack
12+
STACK_YAML: stack-lts-13.yaml
13+
stack-lts-12:
14+
BUILD: stack
15+
ARGS: "--resolver lts-12.26"
16+
stack-lts-11:
17+
BUILD: stack
18+
ARGS: "--resolver lts-11"
19+
stack-lts-10:
20+
BUILD: stack
21+
ARGS: "--resolver lts-10"
22+
stack-lts-9:
23+
BUILD: stack
24+
ARGS: "--resolver lts-9"
25+
maxParallel: 6
26+
steps:
27+
- script: |
28+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
29+
mkdir -p ~/.local/bin
30+
curl -skL https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin;
31+
export PATH=$HOME/.local/bin:$PATH
32+
stack --install-ghc $ARGS test --bench --only-dependencies
33+
stack $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
34+
env:
35+
OS_NAME: ${{ parameters.os }}
36+
displayName: 'Installation ${{parameters.os}} & Test'

.azure/azure-windows-template.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
timeoutInMinutes: 120
4+
pool:
5+
vmImage: ${{ parameters.vmImage }}
6+
strategy:
7+
matrix:
8+
stack-lts-13:
9+
BUILD: stack
10+
STACK_YAML: stack-lts-13.yaml
11+
stack-lts-11:
12+
BUILD: stack
13+
ARGS: "--resolver lts-11"
14+
stack-lts-10:
15+
BUILD: stack
16+
ARGS: "--resolver lts-10"
17+
stack-lts-9:
18+
BUILD: stack
19+
ARGS: "--resolver lts-9"
20+
maxParallel: 4
21+
steps:
22+
- bash: |
23+
chcp 65001
24+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
25+
curl -sSkL http://www.stackage.org/stack/windows-i386 -o /usr/bin/stack.zip
26+
unzip -o /usr/bin/stack.zip -d /usr/bin/
27+
stack --install-ghc $ARGS test --bench --only-dependencies
28+
stack $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
29+
env:
30+
OS_NAME: ${{ parameters.os }}
31+
displayName: 'Installation ${{parameters.os}} & Test'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Linux build](https://travis-ci.org/psibi/tldr-hs.svg?branch=master)](https://travis-ci.org/psibi/tldr-hs)
44
[![Window build](https://ci.appveyor.com/api/projects/status/wlqa2ndsquk1psqs/branch/master?svg=true)](https://ci.appveyor.com/project/psibi/tldr-hs/branch/master)
5+
[![Build Status](https://dev.azure.com/psibi2000/tldr-hs/_apis/build/status/psibi.tldr-hs?branchName=master)](https://dev.azure.com/psibi2000/tldr-hs/_build/latest?definitionId=5?branchName=master)
6+
57
[![Hackage](https://img.shields.io/hackage/v/tldr.svg)](https://hackage.haskell.org/package/tldr)
68
[![Stackage Nightly](http://stackage.org/package/tldr/badge/nightly)](http://stackage.org/nightly/package/tldr)
79
[![Stackage LTS](http://stackage.org/package/tldr/badge/lts)](http://stackage.org/lts/package/tldr)
@@ -32,5 +34,3 @@ Available options:
3234
## Snapshot
3335

3436
![tldr](https://cloud.githubusercontent.com/assets/737477/24076451/2a5a604c-0c57-11e7-9bf7-13d76e8e7f12.png)
35-
36-

azure-pipelines.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This is the complex Azure configuration, which is intended for use
2+
# on open source libraries which need compatibility across multiple GHC
3+
# versions, must work with cabal-install, and should be
4+
# cross-platform. For more information and other options, see:
5+
#
6+
# https://docs.haskellstack.org/en/stable/azure_ci/
7+
#
8+
# Copy these contents into the root directory of your Github project in a file
9+
# named azure-pipelines.yml
10+
#
11+
# For better organization, you split various jobs into seprate parts
12+
# and each of them are controlled via individual file.
13+
jobs:
14+
- template: ./.azure/azure-linux-template.yml
15+
parameters:
16+
name: Linux
17+
vmImage: ubuntu-16.04
18+
os: linux
19+
20+
- template: ./.azure/azure-osx-template.yml
21+
parameters:
22+
name: macOS
23+
vmImage: macOS-10.13
24+
os: osx
25+
26+
- template: ./.azure/azure-windows-template.yml
27+
parameters:
28+
name: Windows
29+
vmImage: vs2017-win2016
30+
os: windows

src/Tldr.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ handleSubsetNodeType _ = mempty
9393

9494

9595
handleSubsetNode :: Node -> Text
96-
handleSubsetNode (Node _ ntype xs) = handleSubsetNodeType ntype <> (T.concat $ Prelude.map handleSubsetNode xs)
96+
handleSubsetNode (Node _ ntype xs) = handleSubsetNodeType ntype <> T.concat (Prelude.map handleSubsetNode xs)
9797

9898
handleParagraph :: [Node] -> Handle -> IO ()
9999
handleParagraph xs handle = TIO.hPutStrLn handle $ T.concat $ Prelude.map handleSubsetNode xs
@@ -105,7 +105,7 @@ handleNode (Node _ ITEM xs) handle = changeConsoleSetting ITEM >> handleParagrap
105105
handleNode (Node _ ntype xs) handle = do
106106
changeConsoleSetting ntype
107107
renderNode ntype handle
108-
mapM_ (\(Node _ ntype' ns) -> renderNode ntype' handle >> mapM_ (flip handleNode $ handle) ns) xs
108+
mapM_ (\(Node _ ntype' ns) -> renderNode ntype' handle >> mapM_ (`handleNode` handle) ns) xs
109109
setSGR [Reset]
110110

111111
parsePage :: FilePath -> IO Node

stack-lts-13.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: lts-13.4
2+
3+
packages:
4+
- '.'

0 commit comments

Comments
 (0)