Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 1 | # 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 Wagner | bdfb933 | 2021-02-02 18:10:06 +0000 | [diff] [blame] | 7 | # 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 Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 10 | # |
| 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 Wagner | bdfb933 | 2021-02-02 18:10:06 +0000 | [diff] [blame] | 15 | parameters: |
| 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 Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 26 | steps: |
Philipp Wagner | bdfb933 | 2021-02-02 18:10:06 +0000 | [diff] [blame] | 27 | - ${{ 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 Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 34 | - bash: | |
| 35 | set -e |
| 36 | test -n "$BUILD_ROOT" |
| 37 | . util/build_consts.sh |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 38 | |
| 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 Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 44 | mkdir -p "$BIN_DIR" |
| 45 | |
Philipp Wagner | bdfb933 | 2021-02-02 18:10:06 +0000 | [diff] [blame] | 46 | echo 'Extracting partial BIN_DIRs:' |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 47 | find "$BUILD_ROOT/downloads" \ |
| 48 | -name 'build-bin.tar' \ |
| 49 | -exec \ |
| 50 | tar -C "$BIN_DIR" \ |
| 51 | --strip-components=1 \ |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 52 | -xvf {} \; |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 53 | |
| 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 Wagner | bdfb933 | 2021-02-02 18:10:06 +0000 | [diff] [blame] | 62 | displayName: Unpack upstream outputs |