tectonic/dist/azure-generic-build.yml

122 lines
4.2 KiB
YAML

# Copyright 2016-2023 the Tectonic Project
# Licensed under the MIT License.
#
# Azure Pipelines template for a standard build-and-test workflow once
# dependencies have been set up. Besides the parameters, the following variables
# are expected:
#
# - TARGET: the build target triple (e.g. "x86_86-unknown-linux-gnu")
# - TOOLCHAIN: the rust toolchain type (e.g., "stable",
# "beta-x86_64-pc-windows-msvc")
parameters:
- name: canaryBuild
type: boolean
default: false
- name: primaryBuild
type: boolean
default: false
- name: defaultFeatures
type: boolean
default: true
- name: explicitFeatures
type: string
default: ''
- name: testIt
type: boolean
default: true
steps:
# We use two variables for feature flagging just because I'm worried about
# quoting the `--features` argument, which will contain spaces.
- bash: |
ffs=
fts=
if [[ $DEFAULT_FEATURES_FLAG == False ]] ; then
ffs="--no-default-features"
fi
if [[ $EXPLICIT_FEATURES == _all_ ]] ; then
ffs="--all-features"
else
fts="$EXPLICIT_FEATURES"
fi
echo "Cargo features for this build: $ffs --features=\"$fts\""
echo "##vso[task.setvariable variable=CARGO_FEATURES_EXPLICIT;]$fts"
echo "##vso[task.setvariable variable=CARGO_FEATURES_FLAGS;]$ffs"
# OK, these have nothing to do with features, but if a build script fails, it
# can be helpful to get a full backtrace.
echo "##vso[task.setvariable variable=RUST_BACKTRACE;]full"
echo "##vso[task.setvariable variable=CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG;]true"
displayName: Set feature flags
env:
DEFAULT_FEATURES_FLAG: ${{ parameters.defaultFeatures }}
EXPLICIT_FEATURES: ${{ parameters.explicitFeatures }}
- bash: cargo build --all --target $TARGET --release $CARGO_FEATURES_FLAGS --features="$CARGO_FEATURES_EXPLICIT" -v
displayName: cargo build for $(TARGET)
- ${{ if parameters.testIt }}:
- bash: cargo test --all --target $TARGET --release $CARGO_FEATURES_FLAGS --features="$CARGO_FEATURES_EXPLICIT"
displayName: cargo test
- bash: |
artifact_dir="$(Build.ArtifactStagingDirectory)/test_failures"
mkdir -p "$artifact_dir"
mv *.observed "$artifact_dir"
mv *.expected "$artifact_dir"
if [ -n "$(ls -A $artifact_dir)" ]; then
echo "##vso[task.setvariable variable=TEST_FAILURE_ARTIFACTS;]true"
fi
displayName: Package test failure files
condition: failed()
- task: PublishPipelineArtifact@1
displayName: Publish packaged test failures
condition: eq(variables['TEST_FAILURE_ARTIFACTS'], true)
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/test_failures'
artifactName: test-failures-$(TARGET)
# For non-canary builds, export artifacts.
- ${{ if eq(parameters.canaryBuild, false) }}:
- bash: |
artifact_dir="$(Build.ArtifactStagingDirectory)/binary-$TARGET"
mkdir -p "$artifact_dir"
cranko cargo package-released-binaries -t $TARGET $artifact_dir -- build --target $TARGET --release
displayName: Package binaries
- task: PublishPipelineArtifact@1
displayName: Publish packaged binary artifact(s)
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/binary-$(TARGET)'
artifactName: binary-$(TARGET)
# If, further, we're the primary build, do some stuff that should only happen
# once among all of the build jobs. TODO: this should probably be handled as
# part of our deployment stage, now that we have a more refined CI/CD workflow.
- ${{ if eq(parameters.primaryBuild, true) }}:
- bash: |
artifact_dir="$(Build.ArtifactStagingDirectory)/appimage"
mkdir -p "$artifact_dir"
if [[ $SOURCE_BRANCH == master ]] ; then
export TECTONIC_APPIMAGE_TAG=continuous
export UPDATE_INFORMATION="gh-releases-zsync|tectonic-typesetting|tectonic|continuous|tectonic-*.AppImage.zsync"
fi
./dist/appimage/build.sh
cp dist/appimage/tectonic-*.AppImage* "$artifact_dir"
displayName: Build AppImage
env:
SOURCE_BRANCH: ${{ variables['Build.SourceBranchName'] }}
- task: PublishPipelineArtifact@1
displayName: Publish AppImage artifact(s)
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/appimage'
artifactName: appimage