Skip to content

Commit 5144dd5

Browse files
psibiborsboom
authored andcommitted
Nightly builds for Stack (#4456)
* Add Azure nightly integration support and bindists generation * Fix failing integration tests
1 parent 530219a commit 5144dd5

File tree

8 files changed

+198
-116
lines changed

8 files changed

+198
-116
lines changed

.azure/azure-nightly-template-linux.yml

Lines changed: 19 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ jobs:
99
matrix:
1010
stack:
1111
BUILD: stack
12-
STACK_YAML: stack.yaml
1312
maxParallel: 1
1413
steps:
1514
- script: |
16-
echo $OS_NAME
1715
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
1816
echo $STACK_ROOT
1917
mkdir -p ~/.local/bin
@@ -23,103 +21,38 @@ jobs:
2321
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
2422
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
2523
./.travis-setup.sh
26-
case "$BUILD" in
27-
style)
28-
export PATH="$(pwd)"/hlint:$PATH
29-
;;
30-
cabal)
31-
export PATH=$HOME/.local/bin:$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:/opt/cabal/$CABALVER/bin:$PATH
32-
;;
33-
*)
34-
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:$PATH
35-
;;
36-
esac
24+
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:$PATH
3725
if ! [ "$BUILD" = style ]; then echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"; fi
38-
set -ex
39-
case "$BUILD" in
40-
style)
41-
./etc/scripts/get-hlint.sh
42-
;;
43-
cabal)
44-
cabal --version
45-
cabal update
46-
rm -f $HOME/.cabal/bin/stack
47-
echo "stack is located at $(which stack)"
48-
stack --version
49-
50-
echo Removing any old dist files
51-
rm -f $(stack --stack-yaml=$STACK_YAML path --dist-dir)/stack-*.tar.gz
52-
53-
echo To avoid custom Cabal setup business, switching temporarily to Simple
54-
cp stack.cabal stack.orig-cabal
55-
sed 's@build-type\:.*@build-type\: Simple@' < stack.orig-cabal > stack.cabal
56-
57-
echo Generating new dist with pvp bounds in the cabal file
58-
stack --system-ghc --stack-yaml=$STACK_YAML sdist --pvp-bounds=both
59-
60-
echo Grabbing the newly generated stack.cabal file from the tarball
61-
tar xf $(stack --system-ghc --compiler=ghc-$GHCVER path --dist-dir)/stack-*.tar.gz --wildcards --strip-components=1 '*/stack.cabal'
62-
63-
echo Switching back to Custom build type
64-
cp stack.cabal stack.orig-cabal
65-
sed 's@build-type\:.*@build-type\: Custom@' < stack.orig-cabal > stack.cabal
66-
rm -f stack.orig-cabal
67-
68-
echo Performing the actual build now that we have the right stack.cabal
69-
cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1
70-
;;
71-
*)
72-
stack --no-terminal build Cabal
73-
stack --no-terminal test --only-dependencies
74-
;;
75-
esac
76-
set +ex
77-
GHC_OPTIONS="-Werror"
78-
if [ $GHCVER = 8.2.1 ]; then GHC_OPTIONS="$GHC_OPTIONS -Wno-missing-home-modules"; fi
7926
set -ex
80-
case "$BUILD" in
81-
style)
82-
hlint src/
83-
hlint src/ --cpp-define=WINDOWS=1
84-
hlint test/ --cpp-simple
85-
;;
86-
stack)
87-
stack --no-terminal test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS"
88-
;;
89-
pedantic)
90-
stack --system-ghc --no-terminal build --pedantic
91-
;;
92-
cabal)
93-
cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options="-O0 $GHC_OPTIONS"
94-
cabal build
95-
cabal test
96-
cabal check
97-
cabal sdist
98-
cabal copy
99-
cd test/integration
100-
true stack setup --compiler=ghc-$GHCVER
101-
true stack test --compiler=ghc-$GHCVER
102-
cd ../..
103-
SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz
104-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
105-
;;
106-
esac
27+
stack --no-terminal install cabal-install
10728
set +ex
10829
env:
10930
OS_NAME: ${{ parameters.os }}
11031
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
11132
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
11233
displayName: 'Installation ${{parameters.os}}'
113-
continueOnError: ${{ eq(variables['STACK_YAML'], 'stack-nightly.yaml') }}
11434
- script: |
115-
stack install
116-
tar czf stack.tar.gz -C $(stack path --local-bin) stack
117-
mv stack.tar.gz $(Build.ArtifactStagingDirectory)
35+
curl https://nixos.org/nix/install | sh
36+
source ~/.profile
37+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
38+
export PATH=$HOME/.local/bin:$PATH;
39+
set -ex
40+
stack test --flag stack:integration-tests stack:test:stack-integration-test
41+
set +ex
42+
displayName: Integration Test
43+
- script: |
44+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
45+
export PATH=$HOME/.local/bin:$PATH;
46+
set -ex
47+
stack install stack --local-bin-path $(Build.ArtifactStagingDirectory)
48+
set +ex
11849
displayName: Gzip Stack
50+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
11951
- task: PublishBuildArtifacts@1
12052
inputs:
12153
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
122-
artifactName: stack-linux-x86_64.tar.gz
54+
artifactName: stack-linux-x86_64
55+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
12356
- script: |
12457
export PATH=$HOME/.local/bin:$PATH;
12558
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
timeoutInMinutes: 180
4+
variables:
5+
- group: AWS_Keys
6+
pool:
7+
vmImage: ${{ parameters.vmImage }}
8+
strategy:
9+
matrix:
10+
stack:
11+
BUILD: stack
12+
maxParallel: 1
13+
steps:
14+
- script: |
15+
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
16+
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
17+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
18+
echo $STACK_ROOT
19+
mkdir -p ~/.local/bin
20+
curl -f -L "https://github.com/fpco/cache-s3/releases/download/${CACHE_S3_VERSION}/cache-s3-${CACHE_S3_VERSION}-${OS_NAME}-x86_64.tar.gz" -o ~/.local/bin/cache-s3.tar.gz
21+
tar xzf ~/.local/bin/cache-s3.tar.gz -C ~/.local/bin
22+
export PATH=$HOME/.local/bin:$PATH;
23+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
24+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
25+
./.travis-setup.sh
26+
brew install mercurial
27+
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/happy/1.19.5/bin:/opt/alex/3.1.7/bin:$PATH
28+
set -ex
29+
stack --no-terminal install cabal-install
30+
set +ex
31+
env:
32+
OS_NAME: ${{ parameters.os }}
33+
displayName: 'Installation ${{parameters.os}}'
34+
- script: |
35+
curl https://nixos.org/nix/install | sh
36+
. ~/.nix-profile/etc/profile.d/nix.sh
37+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
38+
export PATH=$HOME/.local/bin:$PATH;
39+
set -ex
40+
stack test --flag stack:integration-tests stack:test:stack-integration-test
41+
set +ex
42+
displayName: Integration Test
43+
- script: |
44+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
45+
export PATH=$HOME/.local/bin:$PATH;
46+
stack install stack --local-bin-path $(Build.ArtifactStagingDirectory)
47+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
48+
displayName: Gzip Stack
49+
- task: PublishBuildArtifacts@1
50+
inputs:
51+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
52+
artifactName: stack-osx
53+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
54+
- script: |
55+
export PATH=$HOME/.local/bin:$PATH;
56+
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
57+
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
58+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
59+
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
60+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
61+
fi;
62+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
63+
env:
64+
OS_NAME: ${{ parameters.os }}
65+
displayName: 'Cache data'
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
jobs:
2+
- job: ${{ parameters.name }}
3+
timeoutInMinutes: 180
4+
variables:
5+
- group: AWS_Keys
6+
pool:
7+
vmImage: ${{ parameters.vmImage }}
8+
strategy:
9+
matrix:
10+
stack:
11+
BUILD: stack
12+
maxParallel: 1
13+
steps:
14+
- powershell: |
15+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
16+
Invoke-WebRequest -Uri "https://github.com/fpco/cache-s3/releases/download/$env:CACHE_S3_VERSION/cache-s3-$env:CACHE_S3_VERSION-$env:OS_NAME-x86_64.zip" -OutFile $env:TEMP\cache-s3.zip
17+
Expand-Archive $env:TEMP\cache-s3.zip -DestinationPath $env:TEMP\
18+
env:
19+
OS_NAME: ${{ parameters.os }}
20+
displayName: Download binaries
21+
- bash: |
22+
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
23+
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
24+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
25+
export PATH=$PATH:"/C/Program Files/Mercurial/"
26+
export TMP=/D/tmp
27+
choco install hg -y
28+
/tmp/cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
29+
/tmp/cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
30+
curl -sSkL http://www.stackage.org/stack/windows-i386 -o /usr/bin/stack.zip
31+
unzip -o /usr/bin/stack.zip -d /usr/bin/
32+
stack setup
33+
stack --no-terminal install cabal-install
34+
stack --version
35+
env:
36+
OS_NAME: ${{ parameters.os }}
37+
displayName: 'Installation ${{parameters.os}}'
38+
- bash: |
39+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
40+
export PATH=$PATH:"/C/Program Files/Mercurial/"
41+
export TMP=/D/tmp
42+
set -ex
43+
stack test --flag stack:integration-tests stack:test:stack-integration-test
44+
set +ex
45+
displayName: Integration Test
46+
- powershell: |
47+
$env:STACK_ROOT = "$(Build.SourcesDirectory)\.stack-root"
48+
$env:PATH += ";$env:HOME\.local\bin"
49+
stack install stack --local-bin-path $(Build.ArtifactStagingDirectory)
50+
displayName: Gzip Stack
51+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
52+
- task: PublishBuildArtifacts@1
53+
inputs:
54+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
55+
artifactName: stack-windows
56+
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
57+
- bash: |
58+
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)";
59+
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
60+
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
61+
export PATH=$HOME/.local/bin:$PATH;
62+
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
63+
/tmp/cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
64+
fi;
65+
/tmp/cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
66+
env:
67+
OS_NAME: ${{ parameters.os }}
68+
displayName: 'Cache data'

azure-nightly-pipeline.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ variables:
66
AWS_REGION: "us-east-1"
77

88
jobs:
9-
# - template: ./.azure/azure-osx-template.yml
10-
# parameters:
11-
# name: macOS
12-
# vmImage: macOS-10.13
13-
# os: osx
9+
- template: ./.azure/azure-nightly-template-osx.yml
10+
parameters:
11+
name: macOS
12+
vmImage: macOS-10.13
13+
os: osx
1414

1515
- template: ./.azure/azure-nightly-template-linux.yml
1616
parameters:
1717
name: Linux
1818
vmImage: ubuntu-16.04
1919
os: linux
2020

21-
# - template: ./.azure/azure-windows-template.yml
22-
# parameters:
23-
# name: Windows
24-
# vmImage: vs2017-win2016
25-
# os: windows
21+
- template: ./.azure/azure-nightly-template-windows.yml
22+
parameters:
23+
name: Windows
24+
vmImage: vs2017-win2016
25+
os: windows

test/integration/IntegrationSpec.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,18 @@ copyTree toCopy src dst =
129129
where
130130
go srcfp = when (toCopy srcfp) $ liftIO $ do
131131
Just suffix <- return $ stripPrefix src srcfp
132-
let dstfp = dst ++ "/" ++ suffix
132+
let dstfp = dst </> stripHeadSeparator suffix
133133
createDirectoryIfMissing True $ takeDirectory dstfp
134134
createSymbolicLink srcfp dstfp `catch` \(_ :: IOException) ->
135135
copyFile srcfp dstfp -- for Windows
136136

137+
stripHeadSeparator :: FilePath -> FilePath
138+
stripHeadSeparator [] = []
139+
stripHeadSeparator fp@(x:xs) = if isPathSeparator x
140+
then xs
141+
else fp
142+
143+
137144
toCopyRoot :: FilePath -> Bool
138145
toCopyRoot srcfp = any (`isSuffixOf` srcfp)
139146
-- FIXME command line parameters to control how many of these get

test/integration/tests/4095-utf8-pure-nix/Main.hs

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

33
main :: IO ()
44
main = do
5-
stack ["build", "--nix-pure"]
6-
stack ["exec", "--nix-pure", "ShowUnicode"]
5+
if isWindows
6+
then logInfo "Disabled on Windows as Nix is not currently supported on Windows."
7+
else do
8+
stack ["build", "--nix-pure"]
9+
stack ["exec", "--nix-pure", "ShowUnicode"]

test/integration/tests/4105-test-coverage-of-internal-lib/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main :: IO ()
66
main = do
77
stack ["clean"]
88
stack ["build"]
9-
res <- getCoverageLines . snd <$> stackStderr ["test", "--coverage"]
9+
res <- getCoverageLines . snd <$> stackStderr ["test", "--coverage", "--color", "never"]
1010
case res of
1111
_:exprs:_ -> unless ("2/2" `isInfixOf` exprs) testFail
1212
_ -> testFail
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import Control.Monad (unless)
22
import StackTest
3+
import Data.Set
4+
import Data.List (dropWhileEnd)
5+
import Data.Char (isSpace)
36

47
main :: IO ()
58
main = do
69
stackCheckStdout ["freeze"] $ \stdOut -> do
7-
let expected = unlines
8-
[ "resolver:"
9-
, " size: 527165"
10-
, " url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/19.yaml"
11-
, " sha256: 0116ad1779b20ad2c9d6620f172531f13b12bb69867e78f4277157e28865dfd4"
12-
, "extra-deps:"
13-
, "- hackage: a50-0.5@sha256:b8dfcc13dcbb12e444128bb0e17527a2a7a9bd74ca9450d6f6862c4b394ac054,1491"
14-
, " pantry-tree:"
15-
, " size: 409"
16-
, " sha256: a7c6151a18b04afe1f13637627cad4deff91af51d336c4f33e95fc98c64c40d3"
17-
]
18-
unless (stdOut == expected) $
19-
error $ concat [ "Expected: "
20-
, show expected
21-
, "\nActual: "
22-
, show stdOut
10+
let contents = fromList [
11+
"resolver:",
12+
"size: 527165",
13+
"url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/19.yaml",
14+
"sha256: 0116ad1779b20ad2c9d6620f172531f13b12bb69867e78f4277157e28865dfd4",
15+
"extra-deps:",
16+
"pantry-tree:",
17+
"hackage: a50-0.5@sha256:b8dfcc13dcbb12e444128bb0e17527a2a7a9bd74ca9450d6f6862c4b394ac054,1491",
18+
"size: 409",
19+
"sha256: a7c6151a18b04afe1f13637627cad4deff91af51d336c4f33e95fc98c64c40d3"
2320
]
21+
isLeadingYamlSymbol c = c == '-'
22+
trim str = dropWhileEnd isSpace $ dropWhile (\x -> isSpace x || isLeadingYamlSymbol x) str
23+
let stdOutLines = fromList $ Prelude.map trim (lines stdOut)
24+
unless (stdOutLines == contents) $
25+
error $ concat [ "Expected: "
26+
, show contents
27+
, "\nActual: "
28+
, show stdOutLines
29+
]

0 commit comments

Comments
 (0)