Skip to content

Commit

Permalink
.azurepipelines: Expand PlatformCI template for Shell UnitTest
Browse files Browse the repository at this point in the history
Expand PlatformCI build and run steps template for Shell
UnitTest. Add a new parameter unit_test_list to support
building and running specific Shell UnitTest modules.

In stuart_pr_eval step, if the unit_test_list passed from
platform yml file is not null, it will select some packages
from the packages which contain the module in unit_test_list
and set them into a new variable pkgs_to_build base on its
evaluation rule.
In stuart_build step, if unit_test_list is not null,
'${{ parameters.unit_test_list}} -p $(pkgs_to_build)' will be
added into the arguments to build specific UnitTest modules in
pkgs_to_build.
In 'Run to shell' step, if unit_test_list is not null, all the
UnitTest modules built in stuart_build step will runs in shell.

Signed-off-by: Dun Tan <[email protected]>
Cc: Sean Brogan <[email protected]>
Cc: Michael Kubacki <[email protected]>
Cc: Michael D Kinney <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Ray Ni <[email protected]>
  • Loading branch information
td36 committed Nov 22, 2022
1 parent 465d694 commit ab49a31
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions .azurepipelines/templates/platform-build-run-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ parameters:
- name: run_flags
type: string
default: ''
- name: unit_test_list
type: string
default: ''

- name: extra_install_step
type: stepList
Expand All @@ -49,7 +52,9 @@ steps:
displayName: 'Install/Upgrade pip modules'

# Set default
- bash: echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"
- bash: |
echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"
echo "##vso[task.setvariable variable=pkgs_to_build]${{ 'all' }}"
# Fetch the target branch so that pr_eval can diff them.
# Seems like azure pipelines/github changed checkout process in nov 2020.
Expand All @@ -62,7 +67,7 @@ steps:
displayName: Check if ${{ parameters.build_pkg }} need testing
inputs:
filename: stuart_pr_eval
arguments: -c ${{ parameters.build_file }} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} --pr-target origin/$(System.PullRequest.targetBranch) --output-count-format-string "##vso[task.setvariable variable=pkg_count;isOutpout=true]{pkgcount}"
arguments: -c ${{ parameters.build_file }} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} --pr-target origin/$(System.PullRequest.targetBranch) --output-count-format-string "##vso[task.setvariable variable=pkg_count;isOutpout=true]{pkgcount}" --output-csv-format-string "##vso[task.setvariable variable=pkgs_to_build]{pkgcsv}" ${{ parameters.unit_test_list}}
condition: eq(variables['Build.Reason'], 'PullRequest')

# Setup repo
Expand Down Expand Up @@ -97,14 +102,22 @@ steps:
inputs:
filename: stuart_build
arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}
condition: and(gt(variables.pkg_count, 0), succeeded())
condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables.unit_test_list, ''))

# Build specific pkg for UnitTest
- task: CmdLine@1
displayName: Build UnitTest
inputs:
filename: stuart_build
arguments: ${{ parameters.unit_test_list}} -p $(pkgs_to_build) -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}
condition: and(and(gt(variables.pkg_count, 0), succeeded()), not(eq(variables.unit_test_list, '')))

# Run
- task: CmdLine@1
displayName: Run to shell
inputs:
filename: stuart_build
arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags }} --FlashOnly
arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags }} --FlashOnly ${{ parameters.unit_test_list}}
condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))
timeoutInMinutes: 1

Expand Down

0 comments on commit ab49a31

Please sign in to comment.