blob: abd0d499537df7f587a7f8b5f928fc83c76a2330 [file] [log] [blame]
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -06001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
5# Azure template for downloading pipeline step outputs and unpacking them.
6#
Philipp Wagnerbdfb9332021-02-02 18:10:06 +00007# This template will download all artifacts from the upstream jobs listed in
8# `downloadPartialBuildBinFrom` (which are expected to use
9# upload-artifacts-template.yml) and unpack them.
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060010#
11# This template expects that a variable $BUILD_ROOT is set to a writeable
12# directory; the results will be available in $BIN_DIR. See
13# util/build_consts.sh for more information.
14
Philipp Wagnerbdfb9332021-02-02 18:10:06 +000015parameters:
16 # Names of jobs to download a partial $BIN_DIR from.
17 # List all "upstream" jobs here which produce files in $BIN_DIR which are
18 # needed in the current job. In other words, list all jobs which need to be
19 # executed and produce some build outputs before this job can start. The
20 # current job will find all outputs from those upstream jobs in $BIN_DIR and
21 # can use them.
22 - name: downloadPartialBuildBinFrom
23 type: object
24 default: []
25
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060026steps:
Philipp Wagnerbdfb9332021-02-02 18:10:06 +000027 - ${{ each job in parameters.downloadPartialBuildBinFrom }}:
28 - task: DownloadPipelineArtifact@2
29 inputs:
30 buildType: current
31 path: '$(BUILD_ROOT)/downloads/${{ job }}'
32 artifact: "partial-build-bin-${{ job }}"
33 displayName: Downloading partial build-bin directory from job ${{ job }}
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060034 - bash: |
35 set -e
36 test -n "$BUILD_ROOT"
37 . util/build_consts.sh
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000038
39 test -f "$BUILD_ROOT/upstream_bin_dir_contents.txt" && {
40 echo The download-artifacts-template.yml template can be called only once per job.
41 exit 1
42 }
43
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060044 mkdir -p "$BIN_DIR"
45
Philipp Wagnerbdfb9332021-02-02 18:10:06 +000046 echo 'Extracting partial BIN_DIRs:'
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060047 find "$BUILD_ROOT/downloads" \
48 -name 'build-bin.tar' \
49 -exec \
50 tar -C "$BIN_DIR" \
51 --strip-components=1 \
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060052 -xvf {} \;
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000053
54 # Remember all files which were present in the upstream $BIN_DIRs.
55 find "$BIN_DIR" -type f -fprintf "$BUILD_ROOT/upstream_bin_dir_contents.txt" '%P\n'
56
57 echo
58 echo Upstream BIN_DIR contents:
59 echo vvvvvvvvvvvvvvvvvv
60 cat "$BUILD_ROOT/upstream_bin_dir_contents.txt"
61 echo ^^^^^^^^^^^^^^^^^^
Philipp Wagnerbdfb9332021-02-02 18:10:06 +000062 displayName: Unpack upstream outputs