Skip to content

Commit 39904a7

Browse files
committed
Update Rust Cargo Steps
1. Delete the workflow being synced to merge the checks into existing pipeline flows. 2. Call `RustCargoSteps.yml` from PrGate.yml. 3. Allow task specifics to be controlled via the `cargo make all` command in a given repo and simply call that from the pipeline. Signed-off-by: Michael Kubacki <[email protected]>
1 parent 731cc91 commit 39904a7

File tree

3 files changed

+24
-95
lines changed

3 files changed

+24
-95
lines changed

.sync/workflows/leaf/RustCargoSteps.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

Jobs/PrGate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ jobs:
160160
steps:
161161
- ${{ if and(eq(parameters.rust_build, true), ne(item.Value.SelfHostAgent, true)) }}:
162162
- template: ../Steps/RustSetupSteps.yml
163+
- template: ../Steps/RustCargoSteps.yml
164+
parameters:
165+
checkout_self: true
163166
- ${{ if and(contains(parameters.tool_chain_tag, 'CLANGPDB'), ne(item.Value.SelfHostAgent, true)) }}:
164167
- template: ../Steps/SetupToolChainTagPreReqs.yml
165168
- ${{ parameters.extra_steps }}
@@ -172,6 +175,7 @@ jobs:
172175
build_pkgs: ${{ item.Value.Pkgs }}
173176
build_targets: ${{ item.Value.Targets }}
174177
build_archs: ${{ item.Value.ArchList }}
178+
checkout_self: ${{ or(ne(parameters.rust_build, true), eq(item.Value.SelfHostAgent, true)) }}
175179
do_ci_build: ${{ parameters.do_ci_build }}
176180
do_ci_setup: ${{ parameters.do_ci_setup }}
177181
do_non_ci_build: ${{ parameters.do_non_ci_build }}

Steps/RustCargoSteps.yml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
## @file
22
# Azure Pipelines step to run common Cargo commands.
33
#
4-
# Cargo should be installed on the system prior to invoking this template.
4+
# Environment Assumptions:
5+
#
6+
# - Cargo should be installed on the system prior to invoking this template.
7+
# - Cargo make should be installed on the system prior to invoking this template.
8+
# - An `all` task should be defined in the `Makefile.toml` file.
59
#
610
# Copyright (c) Microsoft Corporation. All rights reserved.
711
# SPDX-License-Identifier: BSD-2-Clause-Patent
812
##
913

1014
parameters:
11-
- name: format_command
12-
displayName: Rust Format Command
13-
type: string
14-
default: "cargo fmt --all --check"
15-
- name: test_command
16-
displayName: Rust Test Command
17-
type: string
18-
default: "cargo make test"
19-
- name: build_command
20-
displayName: Rust Build Command
21-
type: string
22-
default: "cargo make build"
15+
- name: checkout_self
16+
displayName: Perform self checkout step
17+
type: boolean
18+
default: false
2319
- name: container_build
2420
displayName: Flag for whether a container is being used
2521
type: boolean
2622
default: false
2723

2824
steps:
2925

26+
- ${{ if eq(parameters.checkout_self, true) }}:
27+
# Repos with local Rust configuration files need to do a self checkout so they are available.
28+
- checkout: self
29+
clean: true
30+
fetchDepth: 0
31+
3032
- task: CmdLine@2
3133
displayName: Setup Cargo Dir Permissions (Linux)
3234
target: host
@@ -39,25 +41,11 @@ steps:
3941
condition: and(eq('${{ parameters.container_build }}', 'true'), eq(variables['Agent.OS'], 'Linux'))
4042

4143
- task: CmdLine@2
42-
displayName: cargo fmt
43-
inputs:
44-
script: ${{ parameters.format_command }}
45-
workingDirectory: '$(System.DefaultWorkingDirectory)'
46-
failOnStandardError: true
47-
condition: succeeded()
48-
49-
- task: CmdLine@2
50-
displayName: cargo make test
51-
inputs:
52-
script: ${{ parameters.test_command }}
53-
workingDirectory: '$(System.DefaultWorkingDirectory)'
54-
failOnStandardError: true
55-
condition: succeeded()
56-
57-
- task: CmdLine@2
58-
displayName: cargo make build
44+
displayName: Cargo Make Checks
45+
env:
46+
RUSTC_BOOTSTRAP: '1'
5947
inputs:
60-
script: ${{ parameters.build_command }}
61-
workingDirectory: '$(System.DefaultWorkingDirectory)'
48+
script: cargo make all
49+
workingDirectory: '$(Build.SourcesDirectory)'
6250
failOnStandardError: true
6351
condition: succeeded()

0 commit comments

Comments
 (0)