Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download latest main #32

Merged
merged 3 commits into from
May 23, 2023
Merged

Download latest main #32

merged 3 commits into from
May 23, 2023

Conversation

joverlee521
Copy link
Contributor

Description of proposed changes

Updates devel/download-latest to pull themain labeled package with the max version and build_number so that our CI diffs of packages only compares against the latest main version.

Related issue(s)

Similar to changes we made in the Nextstrain CLI (nextstrain/cli#280).

Fixes #26

Testing

  • Checks pass

Add explicit check for the latest `main` version by pulling all package
files and then filtering for the `main` label and finding the
max `version`.
Explicitly downloads the max `build_number` for available
distributions so that we are using the latest build.
Comment on lines 11 to 18
curl -fsSL https://api.anaconda.org/package/nextstrain/nextstrain-base/files | jq -r '
map(select(.labels|index("main")))
| map(select(.attrs.subdir == env.CONDA_SUBDIR))
| .[0].download_url
| (max_by(.version) | .version) as $max_version
| .
| map(select(.version == $max_version))
| max_by(.attrs.build_number)
| .download_url
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a was a fun way to learn more jq but please let me know if this is too convoluted or if there's better way do this 🙏

@joverlee521 joverlee521 requested a review from a team May 23, 2023 20:23
curl -fsSL https://api.anaconda.org/release/nextstrain/nextstrain-base/latest | jq -r '
.distributions
curl -fsSL https://api.anaconda.org/package/nextstrain/nextstrain-base/files | jq -r '
map(select(.labels|index("main")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking

For boolean containment, jq has a contains() function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided against contains() because it returns true even for substring containments.

The following returns true:

jq 'contains(["ab"])' <<< '["abcde"]'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! That's a good reason.

devel/download-latest Outdated Show resolved Hide resolved
Thanks @tsibley for pointing out that `max_by` accepts an array of paths and will sort in order of the provided array.

Co-authored-by: Thomas Sibley <[email protected]>
@joverlee521 joverlee521 merged commit 5655133 into main May 23, 2023
@joverlee521 joverlee521 deleted the download-latest-main branch May 23, 2023 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

./devel/download-latest pulls the latest package regardless of label
2 participants