git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] ci: avoid pounding on the poor ci-artifacts container
Date: Fri, 15 May 2020 16:01:16 +0200 (CEST)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.2005151600010.55@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20200513124406.GB1982@danh.dev>

[-- Attachment #1: Type: text/plain, Size: 3828 bytes --]

Hi Danh,

On Wed, 13 May 2020, Đoàn Trần Công Danh wrote:

> 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

  reply	other threads:[~2020-05-15 14:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 20:47 [PATCH] ci: avoid pounding on the poor ci-artifacts container Johannes Schindelin via GitGitGadget
2020-05-12 23:39 ` Junio C Hamano
2020-05-15 13:59   ` Johannes Schindelin
2020-05-13 12:44 ` Đoàn Trần Công Danh
2020-05-15 14:01   ` Johannes Schindelin [this message]
2020-05-15  7:55 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
2020-05-15 15:09   ` Junio C Hamano
2020-05-15 21:35     ` Johannes Schindelin
2020-05-15 21:38       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.QRO.7.76.6.2005151600010.55@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).