File: build-conda-artifacts.yml

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (98 lines) | stat: -rw-r--r-- 3,928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
parameters:
  - name: TestPipeline
    type: boolean
    default: false
  - name: ServiceDirectory
    type: string
    default: ''
  - name: CondaArtifacts
    type: object
    default: []

steps:
  - template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml
    parameters:
      PackageName: "azure-template"
      ServiceDirectory: "template"
      TestPipeline: ${{ parameters.TestPipeline }}

  - task: UsePythonVersion@0
    displayName: 'Use Python $(PythonVersion)'
    inputs:
      versionSpec: $(PythonVersion)

  - script: |
      pip install -r eng/ci_tools.txt
    displayName: 'Prep Environment'

  - pwsh: |
      mkdir $(Agent.BuildDirectory)/conda/
      mkdir $(Agent.BuildDirectory)/conda/output
      mkdir $(Agent.BuildDirectory)/conda/build
      mkdir $(Agent.BuildDirectory)/conda/manifest

      Write-Host "##vso[task.setvariable variable=conda.output]$(Agent.BuildDirectory)/conda/output"
      Write-Host "##vso[task.setvariable variable=conda.build]$(Agent.BuildDirectory)/conda/build"
    displayName: 'Create Conda Working Directories'

  - ${{ each artifact in parameters.CondaArtifacts }}:
    # there may be multiple CondaArtifacts. Be certain $(conda.build) is clean just in case!
    - pwsh:
        Write-Host "Clean up Conda Build Directory $(conda.build)"
        Remove-Item $(conda.build)/* -Recurse -Force
      displayName: 'Clean Up Before Building ${{ artifact.name }}'

    - ${{ each checkout in artifact.checkout }}:
      - template: /eng/pipelines/templates/steps/get-tagged-code.yml
        parameters:
          DestinationDirectory: $(conda.build)/${{checkout.package}}
          Package: ${{checkout.package}}
          CheckoutPath: ${{checkout.checkout_path}}
          Version: ${{checkout.version}}

    - task: PythonScript@0
      displayName: 'Build Source Distribution for ${{ artifact.name }}'
      inputs:
        scriptPath: 'scripts/devops_tasks/build_conda_artifacts.py'
        arguments: >-
          -d "$(conda.output)"
          -b "$(conda.build)"
          -m "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/${{ artifact.meta_source }}"
          -r "${{ artifact.common_root }}"
          -n "${{ artifact.name }}"
          -s "${{ parameters.ServiceDirectory }}"
          -e "$(Build.SourcesDirectory)/eng/conda_env.yml"
          -c "$(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/ci.yml"

    - bash: |
        echo "##vso[task.prependpath]$CONDA/bin"
      displayName: 'Prepend PATH with Conda and INIT'

    - bash: |
        conda env create --name ${{ artifact.name }} --file $(Build.SourcesDirectory)/eng/conda_env.yml
        conda install --yes --quiet --name ${{ artifact.name }} conda-build conda-verify typing-extensions
      displayName: 'Prepare Conda Environment for building ${{ artifact.name }}'

    - bash: |
        source activate ${{ artifact.name }}
        conda-build . --output-folder "$(Agent.BuildDirectory)/conda/output/${{ artifact.name }}" -c $(AzureSDKCondaChannel)
      displayName: 'Activate Conda Environment and Build ${{ artifact.name }}'
      workingDirectory: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/conda-recipe
  
  - template: /eng/common/pipelines/templates/steps/publish-artifact.yml
    parameters:
      ArtifactPath: '$(Agent.BuildDirectory)/conda/output'
      ArtifactName: 'conda'


  - ${{if eq(variables['System.TeamProject'], 'internal') }}:
    - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
      displayName: 'Upload Conda Package SBOM'
      condition: succeededOrFailed()
      inputs:
        BuildDropPath: '$(Agent.BuildDirectory)/conda/manifest'

    - template: /eng/common/pipelines/templates/steps/publish-artifact.yml
      parameters:
        ArtifactPath: '$(Agent.BuildDirectory)/conda/manifest/_manifest'
        ArtifactName: 'conda_manifest'