This page documents how to use Stack on Azure CI.
Note that you have to create azure pipelines for your project and then you need to put the relevant configuration files:
- For simple Azure configuration, copy-paste the
- For complex Azure configuration, you need to take the below linked four files
and put all of them into the
For a more detailed explanation, you can read further.
Simple and Complex configuration¶
We provide two fully baked configuration ready to be used on your projects:
- The simple Azure configuration
is intended for applications that do not require multiple GHC support or
cross-platform support. It builds and tests your project with just the
settings present in your
- The complex Azure configuration is intended for projects that need to support multiple GHC versions and multiple operating systems, such as open source libraries to be released to Hackage. It tests against Stack for different snapshots on Linux, macOS and Windows. These are the files for the complex configuration:
- azure-pipelines.yml : This is the starter file used by the Azure CI.
- azure-linux-template.yml : Template for Azure Linux build
- azure-osx-template.yml : Template for Azure macOS build
- azure-windows-template.yml : Template for Azure Windows build
It is likely going to be necessary to modify this configuration to match
the needs of your project, such as tweaking the build matrix to alter
which GHC versions you test against, or to specify GHC-version-specific
`stack.yaml` files if necessary. Don't be surprised if it doesn't work the
first time around. See the multiple GHC section below for more
Creating Azure Pipelines¶
Each of these configurations is ready to be used immediately. But before we go into where to put them, we have to create pipeline for your project in Azure CI platform:
- Go to dev.azure.com. You have to initially sign-in to your microsoft account there.
- Once you have logged in to your Microsoft account, you have to sign in to Azure devops from there.
- You will be greeted with a dashboard where you can create your projects.
- Click the "Create Project" button and fill the relevant information in the dialog and then click the "Create" button.
- This will lead you to the project dashboard page where you can create pipelines.
- Click on "Pipelines" in the left menu. This will load the pipelines page on the right.
- Click on the button "New Pipeline" and you have to follow through the wizard
there. You need to choose your github repository (or Azure repos) and follow
the wizard. Note that in the
you have to select the "Starter Pipeline". This will open up an
You can leave the existing YAML configuration there as it is and click the
"Save and run" button. That will popup a
Select the relevant option and click "Save and run" button. (Note that this
step would have created
azure-pipelines.ymlin your repository. You have to replace that with the appropriate configuration file.)
The rest of this document explains the details of common Azure configurations for those of you who want to tweak the above configuration files or write your own.
Note: both Azure and Stack infrastructures are actively developed. We try to document best practices at the moment.
Note that you need at least one agent to build your code. You can specify which virtual image you want to choose using this configuration:
The other popular options are
windows-latest for macOS and
Windows respectively. You can find the
here. You also have the option to select a specific supported ubuntu version
Currently there is only one reasonable way to install Stack: fetch a precompiled binary from GitHub.
There are two ways to install GHC:
- Let Stack download GHC
- Install GHC using apt package manger. This method is only applicable for Debian based images.
But we only use the first method of using Stack to download GHC.
Multiple GHC - parametrised builds¶
For different GHC versions, you probably want to use different project-level
configuration files (
stack.yaml, by default). If you don't want to put a
stack.yaml for a particular snapshot and still want to test it, you
have specify your snapshot argument in
ARGS environment variable (you will see
an example below).
After the environment setup, actual test running is simple. Command:
Some Stack commands will run for long time. To avoid timeouts, use the timeoutInMinutes for jobs.