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

[docs] Adds basic CI yaml for GitHub Actions #10212

Merged
merged 5 commits into from
Dec 20, 2021
Merged
Changes from 3 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
29 changes: 29 additions & 0 deletions src/doc/src/guide/continuous-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@ will not fail your overall build. Please see the [Travis CI Rust
documentation](https://docs.travis-ci.com/user/languages/rust/) for more
information.

### GitHub Actions

To test your package on GitHub Actions, here is a sample `.github/workflows/ci.yml` file:

```yaml
name: Cargo Build & Test

on:
push:
SamMorrowDrums marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v2
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --verbose
```

This will test all three release channels, see [GitHub Actions documentation](https://docs.github.com/en/actions) for more information.

Choose a reason for hiding this comment

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

Worth calling out that any failure in nightly will fail the build here, unlike the other examples.

See https://github.com/actions/toolkit/issues/399

Choose a reason for hiding this comment

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

Though we could just update the run command to include ||: as a suffix for nightly.

https://unix.stackexchange.com/questions/78408/which-is-more-idiomatic-in-a-bash-script-true-or

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @misalcedo, while I agree that is an issue, what I think might be good is if at some point there is a better Actions link that is specific to Rust CI, then we could point people there - but I'm hesitant to add complexity to the basic script due to @alexcrichton's comments:

I think that continue-on-error and fail-fast would be removed because we don't necessarily have a great reason for deviating from the GitHub Actions defaults.

I think we should make it somewhat terse and not have too many extra bells and whistles.

These lead me to believe that we've reached an acceptable starting place for Rust users with the current version, and that we could improve this example once a better solution to actions/toolkit#399 is is available?

I'm open to suggestions for how to briefly explain this that CI will fail if any of the matrix jobs fail (and nightly being the one that is likely to without user error), but I think I'm otherwise going to leave this as is, and we should re-visit if anything changes that could improve the basic example or if documentation emerges that I could link out to.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to leave as a comment but otherwise for the copy/paste snippet I agree we shouldn't have it be too too complicated.

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've added a note.


### GitLab CI

To test your package on GitLab CI, here is a sample `.gitlab-ci.yml` file:
Expand Down