You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: content/actions/use-cases-and-examples/building-and-testing/building-and-testing-rust.md
+11-14
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ We recommend that you have a basic understanding of the Rust language. For more
46
46
47
47
## Specifying a Rust version
48
48
49
-
At the time of writing, the default rust compiler version is 1.83.0 rustup is available and can be used to install additional toolchains. For example, the following workflow temporarily sets the toolchain to nightly:
49
+
At the time of writing, the default rust compiler version is 1.83.0 rustup is available and can be used to install additional toolchains.
50
50
51
51
```yaml copy
52
52
- name: Temporarily modify the rust toolchain version
@@ -61,21 +61,22 @@ You can cache and restore dependencies using the following example below. Note t
key: {% raw %} ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
71
+
{% endraw %}
71
72
```
73
+
72
74
If you have a custom requirement or need finer controls for caching, you can take a look at the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see [AUTOTITLE](/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
73
75
74
76
## Building and testing your code
75
77
76
78
You can use the same commands that you use locally to build and test your code. This example workflow demonstrates how to use `cargo build` and `cargo test` in a job:
- name: Run tests in "${{ matrix.BUILD_TARGET }}" mode
93
94
run: cargo test --profile ${{ matrix.BUILD_TARGET }}
94
95
```
96
+
95
97
Note that the `release` keyword used above, corresponds to a cargo profile. You can use any [profile](https://doc.rust-lang.org/cargo/reference/profiles.html) you have defined in your `Cargo.toml` file.
96
98
97
99
## Upload artifacts
98
100
99
101
In case publishing artifacts is needed, but not to crates.io, the following example demonstrates how to upload artifacts to the workflow run:
102
+
100
103
```yaml copy
101
-
- name: Upload Telegram Bot
102
-
uses: actions/upload-artifact@v4
103
-
with:
104
-
name: cndk8-telegram-bot
105
-
path: target/${{ matrix.BUILD_TARGET }}/telegram
106
104
- name: Upload hello app
107
-
uses: actions/upload-artifact@v4
105
+
uses: {% data reusables.actions.action-upload-artifact %}
108
106
with:
109
107
name: cndk8-hello
110
108
path: target/${{ matrix.BUILD_TARGET }}/cndk8
111
109
```
112
110
113
111
And to use them on a different job, i.e publishing:
114
112
115
-
116
113
```yaml copy
117
114
- name: Download hello app
118
-
uses: actions/download-artifact@v4
115
+
uses: {% data reusables.actions.action-download-artifact %}
119
116
with:
120
117
name: cndk8-hello
121
118
path: ./cndk8-hello
@@ -132,7 +129,6 @@ And to use them on a different job, i.e publishing:
132
129
Once you have setup your workflow to build and test your code, you can alternatively use a secret to login to crates.io and publish your package.
133
130
134
131
```yaml copy
135
-
- uses: actions/checkout@v4
136
132
- name: login into crates.io
137
133
run: cargo login ${{ secrets.CRATES_IO }}
138
134
- name: Build binaries in "release" mode
@@ -142,5 +138,6 @@ Once you have setup your workflow to build and test your code, you can alternati
142
138
- name: "Publish to crates.io"
143
139
run: cargo publish # publishes your crate as a library that can be added as a dependency
144
140
```
141
+
145
142
As an example of how packages are published, see the [cndk8 0.1.0](https://crates.io/crates/cndk8/0.1.0). In the case that there are errors with Metadata check
146
143
your [manifest](https://doc.rust-lang.org/cargo/reference/manifest.html) Cargo.toml, when its about dirty directory check your Cargo.lock, and read the corresponding documentation.
0 commit comments