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
+10-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,21 @@ You can cache and restore dependencies using the following example below. Note t
key: {% raw %}${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}{% endraw %}
71
71
```
72
+
72
73
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
74
74
75
## Building and testing your code
75
76
76
77
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
93
run: cargo test --profile ${{ matrix.BUILD_TARGET }}
94
94
```
95
+
95
96
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
97
97
98
## Upload artifacts
98
99
99
100
In case publishing artifacts is needed, but not to crates.io, the following example demonstrates how to upload artifacts to the workflow run:
101
+
100
102
```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
103
- name: Upload hello app
107
-
uses: actions/upload-artifact@v4
104
+
uses: {% data reusables.actions.action-upload-artifact %}
108
105
with:
109
106
name: cndk8-hello
110
107
path: target/${{ matrix.BUILD_TARGET }}/cndk8
111
108
```
112
109
113
110
And to use them on a different job, i.e publishing:
114
111
115
-
116
112
```yaml copy
117
113
- name: Download hello app
118
-
uses: actions/download-artifact@v4
114
+
uses: {% data reusables.actions.action-download-artifact %}
119
115
with:
120
116
name: cndk8-hello
121
117
path: ./cndk8-hello
@@ -132,7 +128,6 @@ And to use them on a different job, i.e publishing:
132
128
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
129
134
130
```yaml copy
135
-
- uses: actions/checkout@v4
136
131
- name: login into crates.io
137
132
run: cargo login ${{ secrets.CRATES_IO }}
138
133
- name: Build binaries in "release" mode
@@ -142,5 +137,6 @@ Once you have setup your workflow to build and test your code, you can alternati
142
137
- name: "Publish to crates.io"
143
138
run: cargo publish # publishes your crate as a library that can be added as a dependency
144
139
```
140
+
145
141
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
142
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