Skip to content

Commit

Permalink
[devops] Move bash script from yaml to it's own bash file. (#15861)
Browse files Browse the repository at this point in the history
This makes it easier to both read & write bash code (syntax highlighting in
the script file, shellscript to validate, etc.), as well as testing out the
script locally.
  • Loading branch information
rolfbjarne authored Sep 6, 2022
1 parent 4cc0bde commit ea60486
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 55 deletions.
51 changes: 51 additions & 0 deletions tools/devops/automation/scripts/bash/install-workloads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash -eux

set -o pipefail
IFS=$'\n\t '

env | sort

make global.json
make -C builds dotnet

var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=DOTNET)
DOTNET=${var#*=}
echo "Using dotnet found at $DOTNET"

var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=DOTNET_PLATFORMS)
DOTNET_PLATFORMS=${var#*=}
echo "Dotnet platforms are '$DOTNET_PLATFORMS'"

var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-abspath-variable VARIABLE=DOTNET_NUPKG_DIR)
DOTNET_NUPKG_DIR=${var#*=}
echo "Using nuget dir $DOTNET_NUPKG_DIR"

ROLLBACK_PATH="$BUILD_SOURCESDIRECTORY/artifacts/WorkloadRollback/WorkloadRollback.json"

echo "Rollback file contents:"
cat "$ROLLBACK_PATH"

mkdir -p "$DOTNET_NUPKG_DIR"
ls -R "$BUILD_SOURCESDIRECTORY/artifacts/not-signed-package"
cp "$BUILD_SOURCESDIRECTORY/artifacts/not-signed-package/"*.nupkg "$DOTNET_NUPKG_DIR"
cp "$BUILD_SOURCESDIRECTORY/artifacts/not-signed-package/"*.pkg "$DOTNET_NUPKG_DIR"
ls -R "$DOTNET_NUPKG_DIR"

NUGET_SOURCES=$(grep https://pkgs.dev.azure.com ./NuGet.config | sed -e 's/.*value="//' -e 's/".*//')
SOURCES=()
for source in $NUGET_SOURCES; do
SOURCES+=(--source)
SOURCES+=("$source")
done

PLATFORMS=()
for platform in $DOTNET_PLATFORMS; do
CURRENT=$(echo "$platform" | tr "[:upper:]" "[:lower:]")
PLATFORMS+=("$CURRENT")
done

$DOTNET workload install --from-rollback-file "$ROLLBACK_PATH" --source "$DOTNET_NUPKG_DIR" "${SOURCES[@]}" --verbosity diag "${PLATFORMS[@]}"

var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=DOTNET_DIR)
DOTNET_DIR=${var#*=}
ls -lR "$DOTNET_DIR"
57 changes: 2 additions & 55 deletions tools/devops/automation/templates/tests/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ steps:
allowFailedBuilds: true
path: $(Build.SourcesDirectory)/artifacts

- bash: |
set -x
set -e
make global.json
make -C builds dotnet
workingDirectory: $(System.DefaultWorkingDirectory)/xamarin-macios
displayName: Bootstrap dotnet
timeoutInMinutes: 30

- pwsh: |
$workloadPath = "$(Build.SourcesDirectory)/artifacts/WorkloadRollback/WorkloadRollback.json"
$versionData = Get-Content $workloadPath | ConvertFrom-Json
Expand All @@ -100,53 +90,10 @@ steps:
Write-Host "##vso[task.setvariable variable=MACCATALYST_WORKLOAD_VERSION;]$catalystVersion"
displayName: 'Set workload versions for xtro'

- bash: |
set -x
set -e
var=$(make -C $(Build.SourcesDirectory)/xamarin-macios/tools/devops print-variable VARIABLE=DOTNET)
DOTNET=${var#*=}
echo "Using dotnet found at $DOTNET"
var=$(make -C $(Build.SourcesDirectory)/xamarin-macios/tools/devops print-variable VARIABLE=DOTNET_PLATFORMS)
DOTNET_PLATFORMS=${var#*=}
echo "Dotnet platforms are '$DOTNET_PLATFORMS'"
var=$(make -C $(Build.SourcesDirectory)/xamarin-macios/tools/devops print-abspath-variable VARIABLE=DOTNET_NUPKG_DIR)
DOTNET_NUPKG_DIR=${var#*=}
echo "Using nuget dir $DOTNET_NUPKG_DIR"
ROLLBACK_PATH="$(Build.SourcesDirectory)/artifacts/WorkloadRollback/WorkloadRollback.json"
echo "Rollback file contents:"
echo "$(cat $ROLLBACK_PATH)"
mkdir -p $DOTNET_NUPKG_DIR
ls -R $(Build.SourcesDirectory)/artifacts/not-signed-package
cp $(Build.SourcesDirectory)/artifacts/not-signed-package/*.nupkg $DOTNET_NUPKG_DIR
cp $(Build.SourcesDirectory)/artifacts/not-signed-package/*.pkg $DOTNET_NUPKG_DIR
ls -R $DOTNET_NUPKG_DIR
NUGET_SOURCES=$(grep https://pkgs.dev.azure.com ./NuGet.config | sed -e 's/.*value="//' -e 's/".*//')
SOURCES=""
for source in $NUGET_SOURCES; do
SOURCES="$SOURCES --source $source"
done
PLATFORMS=""
for platform in $DOTNET_PLATFORMS; do
CURRENT=$(echo $platform | tr A-Z a-z)
PLATFORMS="$PLATFORMS $CURRENT"
done
$DOTNET workload install --from-rollback-file $ROLLBACK_PATH --source $DOTNET_NUPKG_DIR $SOURCES --verbosity diag $PLATFORMS
var=$(make -C $(Build.SourcesDirectory)/xamarin-macios/tools/devops print-variable VARIABLE=DOTNET_DIR)
DOTNET_DIR=${var#*=}
ls -lR $DOTNET_DIR
- bash: $(System.DefaultWorkingDirectory)/xamarin-macios/tools/devops/automation/scripts/bash/install-workloads.sh
workingDirectory: $(System.DefaultWorkingDirectory)/xamarin-macios
displayName: 'Install dotnet workloads'
timeoutInMinutes: 45

- bash: |
set -x
Expand Down

5 comments on commit ea60486

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.