From bb48cd5b71777e3cc64bea763dea0854d1025afd Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Fri, 17 Dec 2021 11:37:42 +0100 Subject: [PATCH 1/5] Adds basic CI yaml for GitHub Actions --- src/doc/src/guide/continuous-integration.md | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/doc/src/guide/continuous-integration.md b/src/doc/src/guide/continuous-integration.md index 5eeeddf85c0..b9a8f277958 100644 --- a/src/doc/src/guide/continuous-integration.md +++ b/src/doc/src/guide/continuous-integration.md @@ -21,6 +21,41 @@ 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: + +jobs: + build_and_test: + name: Rust project - latest + runs-on: ${{ matrix.operating-system }} + continue-on-error: true + strategy: + fail-fast: false + matrix: + toolchain: + - stable + - beta + - nightly + operating-system: + - "ubuntu-latest" + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + - run: cargo build --verbose + - run: cargo test --verbose +``` + +This will test all three release channels, see [actions-rs documentation](https://github.com/actions-rs/cargo) and [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. + ### GitLab CI To test your package on GitLab CI, here is a sample `.gitlab-ci.yml` file: From 75720475293c2828c7562edf33ed155792d8d1d6 Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Fri, 17 Dec 2021 12:02:13 +0100 Subject: [PATCH 2/5] add in override flag to set default cargo toolchain --- src/doc/src/guide/continuous-integration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/src/guide/continuous-integration.md b/src/doc/src/guide/continuous-integration.md index b9a8f277958..996c530d8c3 100644 --- a/src/doc/src/guide/continuous-integration.md +++ b/src/doc/src/guide/continuous-integration.md @@ -50,6 +50,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.toolchain }} + override: true - run: cargo build --verbose - run: cargo test --verbose ``` From e91db920a02f789300b2a307a841e007c2d1eccc Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Fri, 17 Dec 2021 20:02:11 +0100 Subject: [PATCH 3/5] further simplify the workflow --- src/doc/src/guide/continuous-integration.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/doc/src/guide/continuous-integration.md b/src/doc/src/guide/continuous-integration.md index 996c530d8c3..443fc01bf09 100644 --- a/src/doc/src/guide/continuous-integration.md +++ b/src/doc/src/guide/continuous-integration.md @@ -34,28 +34,21 @@ on: jobs: build_and_test: name: Rust project - latest - runs-on: ${{ matrix.operating-system }} - continue-on-error: true + runs-on: ubuntu-latest strategy: - fail-fast: false matrix: toolchain: - stable - beta - nightly - operating-system: - - "ubuntu-latest" steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.toolchain }} - override: true + - 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 [actions-rs documentation](https://github.com/actions-rs/cargo) and [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. +This will test all three release channels, see [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. ### GitLab CI From a7a60a542147e86d346ef82cd1b1f3468d951cae Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Mon, 20 Dec 2021 15:49:10 +0100 Subject: [PATCH 4/5] add information on starter workflow --- src/doc/src/guide/continuous-integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/src/guide/continuous-integration.md b/src/doc/src/guide/continuous-integration.md index 443fc01bf09..b848eedabb5 100644 --- a/src/doc/src/guide/continuous-integration.md +++ b/src/doc/src/guide/continuous-integration.md @@ -48,7 +48,7 @@ jobs: - run: cargo test --verbose ``` -This will test all three release channels, see [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. +This will test all three release channels. You can also click `"Actions" > "new workflow"` in the GitHub UI and select Rust to add the [default configuration](https://github.com/actions/starter-workflows/blob/main/ci/rust.yml) to your repo. See [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. ### GitLab CI From deee87c42857ca34085d94d94b07de6b421347ac Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Mon, 20 Dec 2021 16:43:03 +0100 Subject: [PATCH 5/5] add pull_request trigger and update add note on fail case --- src/doc/src/guide/continuous-integration.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doc/src/guide/continuous-integration.md b/src/doc/src/guide/continuous-integration.md index b848eedabb5..ccaf1ba8efc 100644 --- a/src/doc/src/guide/continuous-integration.md +++ b/src/doc/src/guide/continuous-integration.md @@ -30,6 +30,10 @@ name: Cargo Build & Test on: push: + pull_request: + +env: + CARGO_TERM_COLOR: always jobs: build_and_test: @@ -46,9 +50,10 @@ jobs: - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: cargo build --verbose - run: cargo test --verbose + ``` -This will test all three release channels. You can also click `"Actions" > "new workflow"` in the GitHub UI and select Rust to add the [default configuration](https://github.com/actions/starter-workflows/blob/main/ci/rust.yml) to your repo. See [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. +This will test all three release channels (note a failure in any toolchain version will fail the entire job). You can also click `"Actions" > "new workflow"` in the GitHub UI and select Rust to add the [default configuration](https://github.com/actions/starter-workflows/blob/main/ci/rust.yml) to your repo. See [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. ### GitLab CI