|
3 | 3 | # shellcheck disable=SC1090,SC1091
|
4 | 4 | source "$HOME/.profile"
|
5 | 5 |
|
6 |
| -# due to how the repostiory is cloned with --depth=100 (see aspect terraform docs), we need to fetch the tags manually |
7 |
| -# we don't want to fetch all the tags, so here: |
8 |
| -# 1. Get a list of tags from the remote |
9 |
| -# 2. Sort them |
10 |
| -# 3. Get the last $COUNT tags |
11 |
| -# 4. Parse them so that we only get the tag |
12 |
| -# 5. Then loop through every tag and fetch it |
13 |
| -COUNT=10 |
14 |
| -echo "~~~ :git: Fetching last $COUNT tags" |
15 |
| -git ls-remote --tags origin | sort -t '/' -k 3 -V | tail -n $COUNT | awk -F'/' '{gsub(/\^\{\}$/, "", $3); print $3}' | uniq | while read -r tag; do |
16 |
| - git fetch -v origin tag "$tag" |
| 6 | +function fetch_tags() { |
| 7 | + # ref relevant terraform: https://github.com/sourcegraph/infra-aspect-dev/blob/main/aspect/workflows.tf#L71 |
| 8 | + # ref docs about above terraform: https://pro.aspect.build/workflows/terraform/workflows#input_bk_runner_groups |
| 9 | + # due to how the repostiory is cloned with --depth=100 (see aspect terraform docs), we need to fetch the tags manually |
| 10 | + # we don't want to fetch all the tags, so here: |
| 11 | + # 1. Get a list of tags from the remote |
| 12 | + # 2. Sort them |
| 13 | + # 3. Get the last $COUNT tags |
| 14 | + # 4. Parse them so that we only get the tag |
| 15 | + # 5. Then loop through every tag and fetch it |
| 16 | + COUNT=10 |
| 17 | + echo "~~~ :git: Fetching last $COUNT tags" |
| 18 | + git ls-remote --tags origin | sort -t '/' -k 3 -V | tail -n $COUNT | awk -F'/' '{gsub(/\^\{\}$/, "", $3); print $3}' | uniq | while read -r tag; do |
| 19 | + # we don't use deepen here since during testing it caused more history to be fetched than just the history for the tag which incured a ~40s cost over 5s with just fetch tag |
| 20 | + git fetch -v origin tag "$tag" |
| 21 | + done |
| 22 | +} |
| 23 | + |
| 24 | +steps_with_tags=(":pipeline: Generate pipeline" ":bazel: Test" ":bazel: Integration/E2E (Test)") |
| 25 | +for step in "${steps_with_tags[@]}"; do |
| 26 | + if [[ "$BUILDKITE_LABEL" == "$step" ]]; then |
| 27 | + fetch_tags |
| 28 | + fi |
17 | 29 | done
|
18 | 30 |
|
19 | 31 | # Link command wrapper scripts so we can have more readable steps in the buildkite UI
|
|
0 commit comments