Re: [PATCH] ci: avoid pounding on the poor ci-artifacts container
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 15, 2020, 14:01 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2005151600010.55@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20200513124406.GB1982@danh.dev>
Hi Danh,
On Wed, 13 May 2020, Đoàn Trần Công Danh wrote:
Show 68 quoted lines
> On 2020-05-12 20:47:10+0000, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > - run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> > + run: |
> > + ## Add `json_pp` to the search path
> > + PATH=$PATH:/usr/bin/core_perl
> > +
> > + ## Get artifact
> > + urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
> > + id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
> > + json_pp |
> > + sed -n 's/^ "id" : \([1-9][0-9]*\).*/\1/p')
> > + download_url="$(curl "$urlbase/$id/artifacts" |
> > + json_pp |
> > + sed -n '/^ {/{:1;N;/\n }/b2;b1;:2;/"name" : "git-sdk-64-minimal"/{s/.*"downloadUrl" : "\([^\"]*\).*/\1/p}}')"
>
> Hi Dscho,
>
> I wonder if it's acceptable to introduce jq (already installed in
> GitHub Actions and Travis) into our codebase (only in GitHub Actions).
>
> If yes, I think this will be easier to follow than depending on static
> number of space and sed branching.
> ---------------------8<-----------------
> diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
> index e2e1611aa2..482df46651 100644
> --- a/.github/workflows/main.yml
> +++ b/.github/workflows/main.yml
> @@ -13,17 +13,12 @@ jobs:
> - name: download git-sdk-64-minimal
> shell: bash
> run: |
> - ## Add `json_pp` to the search path
> - PATH=$PATH:/usr/bin/core_perl
> -
> ## Get artifact
> urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
> id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
> - json_pp |
> - sed -n 's/^ "id" : \([1-9][0-9]*\).*/\1/p')
> + jq -r ".value[] | .id")
> download_url="$(curl "$urlbase/$id/artifacts" |
> - json_pp |
> - sed -n '/^ {/{:1;N;/\n }/b2;b1;:2;/"name" : "git-sdk-64-minimal"/{s/.*"downloadUrl" : "\([^\"]*\).*/\1/p}}')"
> + jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
> curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
> -o artifacts.zip "$download_url"
>
> @@ -104,17 +99,12 @@ jobs:
> - name: download git-sdk-64-minimal
> shell: bash
> run: |
> - ## Add `json_pp` to the search path
> - PATH=$PATH:/usr/bin/core_perl
> -
> ## Get artifact
> urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
> id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
> - json_pp |
> - sed -n 's/^ "id" : \([1-9][0-9]*\).*/\1/p')
> + jq -r ".value[] | .id")
> download_url="$(curl "$urlbase/$id/artifacts" |
> - json_pp |
> - sed -n '/^ {/{:1;N;/\n }/b2;b1;:2;/"name" : "git-sdk-64-minimal"/{s/.*"downloadUrl" : "\([^\"]*\).*/\1/p}}')"
> + jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
> curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
> -o artifacts.zip "$download_url"
>
> ----------->8------------Thank you for that. Indeed, I should have checked whether `jq` is available on the Windows build agents (and then I should have learned how to hold that tool right).
I sent out a v2 with this change, and I already merged that version into Git for Windows' `master` branch in preparation for v2.27.0-rc0.
Thanks, Dscho