rust - 使用 Rust,您如何在发布到 crate.io 之前执行平台测试?
问题描述
我正在研究一个framework
我正在测试我的Mac
. 最终,我想发布到crate.io
. 我希望它不会因为糟糕的平台测试而崩溃。有没有一种方法可以在所有或至少大多数当前部署平台上进行测试,而无需直接访问这些平台?例如,我无权访问Windows
盒子。
解决方案
如果您将代码托管在 github 上,您可以设置 github 操作以在多个平台上构建和测试您的代码。
我有两组在我的代码上运行的操作。
- 一个运行测试,并在 Linux 上进行剪辑和检查
rust fmt
,仅用于正常的推送和拉取请求 - 另一个在设置发布分支并创建发布时运行,运行测试并构建和上传 Windows、Linux 和 macOS 的发布二进制文件。
您可以在这里看到完整的文件。
但是结合这些和简化意味着要对每个推送和拉取请求进行测试,您将创建一个.github/workflows/testing.yml
像这样的文件(未经测试):
name: Run Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build_matrix:
name: Run tests for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
name: [linux, windows, macos]
include:
- name: linux
os: ubuntu-latest
- name: windows
os: windows-latest
- name: macos
os: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Test
run: cargo test
推荐阅读
- c# - 如何防止“线程已以代码 0 (0x0) 退出”?
- cakephp - CakePHP slug 将我的孟加拉语文本转换为英语
- linux - 带有 Docker 映像的 OS Iso
- c# - 如何将 Asp.Net Core WebApi 与 React.js 集成?
- javascript - div容器内的滚动文本不可见
- csv - 架构验证失败的 Spark 错误
- powerbi - Power BI“绑定到参数”对于基于日历的表不可见
- amazon-s3 - Nifi 将流文件属性添加到 S3 对象(PutS3Object)元数据
- android - 有什么替代flutter包call_log的方法吗?
- amazon-web-services - 将 AWS 策略存储在代码库中是一种不好的做法吗?