docker.yml 2.04 KB
Newer Older
1 2
# These are the steps used in a container-based build in VSTS.
steps:
3 4 5 6
- ${{ if eq(parameters.qemu, 'true') }}:
  - script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
    displayName: 'Register Docker QEMU'

7 8 9 10 11 12 13 14
- task: cache@2
  displayName: Cache Docker layers
  inputs:
    key: docker
    path: /tmp/dockercache
- script: |
    if [ -f /tmp/dockercache/${{parameters.docker.image}}.tar ]; then docker load < /tmp/dockercache/${{parameters.docker.image}}.tar; fi
  displayName: 'Load Docker cache'
15
- script: |
16 17 18
    cd $(Build.SourcesDirectory)/azure-pipelines/docker &&
    docker build -t libgit2/${{parameters.docker.image}} --build-arg BASE=${{parameters.docker.base}} -f ${{parameters.docker.image}} . &&
    if [ ! -d /tmp/dockercache ]; then mkdir /tmp/dockercache; fi &&
19
    docker save libgit2/${{parameters.docker.image}} $(docker history -q libgit2/${{parameters.docker.image}} | grep -v '<missing>') > /tmp/dockercache/${{parameters.docker.image}}.tar
20
  displayName: 'Build Docker image'
21 22 23 24
- task: docker@0
  displayName: Build
  inputs:
    action: 'Run an image'
25
    imageName: libgit2/${{ parameters.docker.image }}
26
    volumes: |
27 28
     $(Build.SourcesDirectory):/home/libgit2/source
     $(Build.BinariesDirectory):/home/libgit2/build
29
    envVars: ${{ parameters.environmentVariables }}
30 31
    workDir: '/home/libgit2/build'
    containerCommand: '/home/libgit2/source/azure-pipelines/build.sh'
32 33 34 35 36
    detached: false
- task: docker@0
  displayName: Test
  inputs:
    action: 'Run an image'
37
    imageName: libgit2/${{ parameters.docker.image }}
38
    volumes: |
39 40
     $(Build.SourcesDirectory):/home/libgit2/source
     $(Build.BinariesDirectory):/home/libgit2/build
41
    envVars: ${{ parameters.environmentVariables }}
42 43
    workDir: '/home/libgit2/build'
    containerCommand: '/home/libgit2/source/azure-pipelines/test.sh'
44 45 46 47 48 49 50 51
    detached: false
- task: publishtestresults@2
  displayName: Publish Test Results
  condition: succeededOrFailed()
  inputs:
    testResultsFiles: 'results_*.xml'
    searchFolder: '$(Build.BinariesDirectory)'
    mergeTestResults: true