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

Add instructions for building and testing with Rust #35725

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

foursixnine
Copy link

@foursixnine foursixnine commented Dec 19, 2024

Right now, it's a manual search and replace, I would like to build the docs as I find myself the answers to enable my own rust workflows beyond what https://github.com/foursixnine/cndk8/blob/main/.github/workflows/rust.yml is already doing.

was initially: #35721 but panik.

PoC: Add documentation for rust workflows

Why:

Because there's no documentation on how to properly handle rust stuff on github

would take a look later at github/docs/issues/23181 and see what else fails

What's being changed (if available, include any code snippets, screenshots, or gifs):

So far adding documentation based off the Golang one, and my own journey through https://github.com/foursixnine/cndk8/ and isototest-ng

Commits, PR's will be listed

Check off the following:

Still WIP:

  • Update filename
  • A subject matter expert (SME) has reviewed the technical accuracy of the content in this PR. In most cases, the author can be the SME. Open source contributions may require a SME review from GitHub staff.
  • The changes in this PR meet the docs fundamentals that are required for all content.
  • All CI checks are passing.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Dec 19, 2024
@foursixnine foursixnine changed the title Oxidizegithub Add instructiuons for building and testing rust Dec 19, 2024
@foursixnine foursixnine changed the title Add instructiuons for building and testing rust Add instructions for building and testing with Rust Dec 20, 2024
@nguyenalex836
Copy link
Contributor

@foursixnine Thanks so much for opening a PR! I'll get this triaged for review ✨Just a quick tip - we'd recommend opening an issue before raising a PR, especially for larger scale changes such as this one 💛 This will let our team determine how best to proceed with the concern / issue you are raising, thank you!

@nguyenalex836 nguyenalex836 added content This issue or pull request belongs to the Docs Content team actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Dec 20, 2024
@foursixnine
Copy link
Author

@foursixnine Thanks so much for opening a PR! I'll get this triaged for review ✨Just a quick tip - we'd recommend opening an issue before raising a PR

absolutely! I'm behind on creating the issue, was getting: https://github.com/foursixnine/cndk8/actions/runs/12436473960 in shape before, so I'll get back to creating the issue over the weekend :) to not lose momentum!

especially for larger scale changes such as this one 💛 This will let our team determine how best to proceed with the concern / issue you are raising, thank you!

awesome! I might need guidance, as I'm only looking at only gh community

@nguyenalex836
Copy link
Contributor

@foursixnine Ah gotcha, thank you! ✨ Well I hope you get to have a restful and wonderful weekend 💛

@foursixnine
Copy link
Author

foursixnine commented Dec 22, 2024

@foursixnine Ah gotcha, thank you! ✨ Well I hope you get to have a restful and wonderful weekend 💛

@nguyenalex836 : A lot of rest is being achieved :D - created #35747 as the issue for this and following Pull requests (if any) related to this.

@nguyenalex836 nguyenalex836 linked an issue Dec 23, 2024 that may be closed by this pull request
5 tasks
Copy link
Contributor

@janbrasna janbrasna left a comment

Choose a reason for hiding this comment

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

It's referred as WIP/PoC in a few places (although not marked as "Draft" so it appears as ready for review…) therefore this may be preliminary, but to make sure it's tracked in case:

- CI
shortTitle: Build & test Rust
redirect_from:
- /actions/automating-builds-and-tests/building-and-testing-rust
Copy link
Contributor

Choose a reason for hiding this comment

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

Has there been any previous content at this URL to warrant adding a redirect?


This guide shows you how to build, test, and publish a Rust package.

{% data variables.product.prodname_dotcom %}-hosted runners have a tools cache with preinstalled software, which includes the dependencies for Go. For a full list of up-to-date software and the preinstalled versions of Go, see [AUTOTITLE](/actions/using-github-hosted-runners/about-github-hosted-runners#preinstalled-software).
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the Go toolchain mention intentional?

Comment on lines +5 to +7
fpt: '*'
ghes: '*'
ghec: '*'
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the tracking issue mentions:

"… so It can be reused further by at least community GH (i.e no self hosted runners for now or enterprise features)"

I'm not sure there would be any difference if provisioning the same runners, just felt it's worth noting it's applied to all versions here, while the PR is actually marked as a PoC mentioning only being verified for dotcom and standard runners.

Comment on lines +164 to +183
```yaml copy
name: Go
on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: {% data reusables.actions.action-checkout %}
- name: Setup Go
uses: {% data reusables.actions.action-setup-rust %}
with:
rust-version: '1.8.x'
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test
Copy link
Contributor

Choose a reason for hiding this comment

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

This all looks like Go, not Rust.

steps:
- uses: {% data reusables.actions.action-checkout %}
- name: Setup Go
uses: {% data reusables.actions.action-setup-rust %}
Copy link
Contributor

Choose a reason for hiding this comment

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

action-setup-rust reusable does not exist in this repo.

Comment on lines +87 to +156
### Using a specific Go version

You can configure your job to use a specific version of Go, such as `1.20.8`. Alternatively, you can use semantic version syntax to get the latest minor release. This example uses the latest patch release of Go 1.21:

```yaml copy
- name: Setup Go 1.21.x
uses: {% data reusables.actions.action-setup-go %}
with:
# Semantic version range syntax or exact version of Go
go-version: '1.21.x'
```

## Installing dependencies

You can use `go get` to install dependencies:

```yaml copy
steps:
- uses: {% data reusables.actions.action-checkout %}
- name: Setup Go
uses: {% data reusables.actions.action-setup-go %}
with:
go-version: '1.21.x'
- name: Install dependencies
run: |
go get .
go get example.com/octo-examplemodule
go get example.com/[email protected]
```

### Caching dependencies

You can cache and restore dependencies using the [`setup-go` action](https://github.com/actions/setup-go). By default, caching is {% ifversion actions-setup-go-default-cache-enabled %}enabled when using the `setup-go` action.{% else %}disabled, but you can set the `cache` parameter to `true` to enable it.{% endif %}

{% ifversion actions-setup-go-default-cache-enabled %}
The `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.

You can use the `cache-dependency-path` parameter for cases when multiple dependency files are used, or when they are located in different subdirectories.

```yaml copy
- name: Setup Go
uses: {% data reusables.actions.action-setup-go %}
with:
go-version: '1.17'
cache-dependency-path: subdir/go.sum
```

{% else %}

When caching is enabled, the `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.

```yaml copy
- name: Setup Go
uses: {% data reusables.actions.action-setup-go %}
with:
go-version: '1.21.x'
cache: true
```

Alternatively, you can use the `cache-dependency-path` parameter for cases when multiple dependency files are used, or when they are located in different subdirectories.

```yaml copy
- uses: {% data reusables.actions.action-setup-go %}
with:
go-version: '1.17'
cache: true
cache-dependency-path: subdir/go.sum
```

{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't see how this Go content is relevant here.

Comment on lines +30 to +34
## Using a Rust workflow template

{% data reusables.actions.workflow-templates-get-started %}

{% data variables.product.prodname_dotcom %} provides a Rust workflow template that should work for most basic Rust projects. The subsequent sections of this guide give examples of how you can customize this workflow template.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the template referenced is the starter workflow here: https://github.com/actions/starter-workflows/blob/main/ci/rust.yml — so the following code examples should probably base off of that workflow?

Copy link
Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,184 @@
[---
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a valid front matter here, so it won't even build now.


## Introduction

This guide shows you how to build, test, and publish a Rust package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This guide shows you how to build, test, and publish a Rust package.
This guide shows you how to build and test a Rust package.

Doesn't show how to publish, currently.

1. Filter the selection of workflows by clicking **Continuous integration**.
1. On the "Rust - by {% data variables.product.prodname_actions %}" workflow, click **Configure**.

![Screenshot of the "Choose a workflow" page. The "Configure" button on the "Go" workflow is highlighted with an orange outline.](/assets/images/help/actions/starter-workflow-go.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

This shows a screen shot of a Go starter workflow, not Rust.

go

@foursixnine foursixnine marked this pull request as draft December 27, 2024 09:01
@foursixnine
Copy link
Author

foursixnine commented Dec 27, 2024

It's referred as WIP/PoC in a few places (although not marked as "Draft" so it appears as ready for review…) therefore this may be preliminary, but to make sure it's tracked in case:

Thanks for the review, marked as draft for now - will re-request reviews once final draft ins ready (I started with a copy of the golang one, so that's why go is all over the place :P; that said thanks for the review, some questions I had you're already pointing out missing pieces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team waiting for review Issue/PR is waiting for a writer's review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust: Add instructions for building and testing
3 participants