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

DOC: Advocate for using action from tagged release commit shas #13

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
# Nightly upload

This provides a standard GitHub Action to upload nightly builds to the
scientific-python nightly channel.
This is a GitHub Action that uploads nightly builds to the [scientific-python nightly channel][],
as recommended in [SPEC4 — Using and Creating Nightly Wheels][].

In your Continuous Intregration pipeline once you've built you wheel, you can
use the following snippet to upload to our central nightly repository:
In a GitHub Actions workflow (`.github/workflows/*.yaml`), use the
following snippet to upload built wheels to the repository:

```yml
jobs:
steps:
...
- name: Upload wheel
uses: scientific-python/upload-nightly-action@main
uses: scientific-python/upload-nightly-action@8f0394fd2aa0c85d7364a9958652e8994e06b23c # 0.1.0
Copy link
Member

Choose a reason for hiding this comment

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

could this be a major version instead, the same we do for checkout, or python, or etc?

Copy link
Member

Choose a reason for hiding this comment

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

It depends on how much you trust the project; releases / tags can be removed and replaced, while SHAs are a bit harder to fake. But if you trust official releases made by the org, and you just want to review the new action to make sure nothing big changed, versions are fine.

Copy link
Member

Choose a reason for hiding this comment

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

well, I would rather like to think that the releases made in the scientific-python org are official and trustworthy :)

Copy link
Member

Choose a reason for hiding this comment

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

(after all, we all use a lot of main actions, e.g. the artifact upload one, which is I agree is not super ideal as a best practice)

Copy link
Member

Choose a reason for hiding this comment

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

In that case, if you trust that bunch, versions seem fine ;)

Copy link
Member Author

@matthewfeickert matthewfeickert Jun 1, 2023

Choose a reason for hiding this comment

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

I think that @ksunden gave a good and concise summary in matplotlib/matplotlib#26023 (comment). This is not about trusting orgs or not trusting orgs. It is about trying to be extra security cautious for anything that is publishing distributions to any package index. Is this overkill? Yeah, for sure in my mind, but it also seems like a pattern with no downsides other than you have to have your eyes track a little further across the screen to read the associated tag.

after all, we all use a lot of main actions, e.g. the artifact upload one, which is I agree is not super ideal as a best practice

I will fully agree with you though that tags are better than main, and patch version tags are better than major version tags. Though I'm also willing to agree that there should be additional security hardening than using a latest tag Docker image

FROM continuumio/miniconda3:latest

and so using the SHAs only really helps later releases (0.1.0 is the first commit in the repo). Also this GHA has no CI at all yet. 😬

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the detailed reply. To make this bikeshed really shiny, could I ask you to include some of Kyle's concise commentary as a comment in this readme? Or even just the link you have above would be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I'm in meetings all day today though (on phone now) so feel free to add with the "Add a suggestion" tools and then accept and merge the suggestion if people would like this to get done before tomorrow.

with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{secrets.UPLOAD_TOKEN}}
```

To request access to the repository please open an issue on [this action
Note that we recommend pinning the action against a specific SHA
(rather than a tag), to guard against the unlikely event of upstream
being compromised.

# Updating the action

You can [use Dependabot to keep the GitHub Action up to date][],
with a `.github/dependabot.yml` config file similar to:

```yaml
bsipocz marked this conversation as resolved.
Show resolved Hide resolved
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
```

# Access

To request access to the repository, please open an issue on [this action's
repository](https://github.com/scientific-python/upload-nightly-action). You can
then generate a token at `https://anaconda.org/scientific-python-nightly-wheels/settings/access`
with _Allow write access to the API site_ and _Allow uploads to Standard Python repositories_
permissions and add the token as a secret to your GitHub repository.
with permissions to _Allow write access to the API site_ and _Allow uploads to Standard Python repositories_,
and add the token as a secret to your GitHub repository.

# Using nightly builds in CI

To test those nightly build, you can use the following command to install from
the nightly package.
To test against nightly builds, you can use the following command to install from
the nightly repository:

```sh
python -m pip install \
Expand All @@ -37,29 +58,23 @@ python -m pip install \
matplotlib
```

Note that `--index-url` takes priority over `--extra-index-url`.
Packages, and dependencies, with versions available on the
[nightly package index][] will be installed from there before falling back to
the [Python Package Index][PyPI] to install all remaining requested packages.

```
if package in nightly:
try to install from nightly
else:
try to install from pypi
```
Note that `--index-url` takes priority over `--extra-index-url`, so
that packages, and their dependencies, with versions available in the
nightly channel will be installed before falling back to the [Python
Package Index][PyPI].

If you want to install nightly builds within your conda environment, you can specify an
extra index in your YML file.
To install nightly builds within a conda environment, specify an extra
index in your `environment.yml`:

```yml
name: test
dependencies:
- pip
- pip:
- --pre --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple
- matplotlib
```

[nightly package index]: https://anaconda.org/scientific-python-nightly-wheels
[use Dependabot to keep the GitHub Action up to date]: https://learn.scientific-python.org/development/guides/gha_basic/#updating
[PyPI]: https://pypi.org/
[scientific-python nightly channel]: https://anaconda.org/scientific-python-nightly-wheels
[SPEC4 — Using and Creating Nightly Wheels]: https://scientific-python.org/specs/spec-0004/