Last active
May 9, 2023 14:05
-
-
Save RichieBzzzt/8b6345d653433371ca56d3464cc04065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
none | |
pr: | |
autoCancel: true | |
branches: | |
include: | |
- none | |
pool: | |
vmImage: 'ubuntu-latest' | |
name: $(BuildDefinitionName)_$(VersionNumber)_$(SourceBranchName) | |
variables: | |
- name: "Version.Major" | |
value: "0" | |
- name: "Version.Minor" | |
value: "27" | |
- name: "Version.Revision" | |
value: $[counter(variables['Version.Minor'], 0)] | |
- name: VersionNumber | |
value: $(Version.Major).$(Version.Minor).$(Version.Revision) | |
- name: python_version | |
value: "3.8" | |
stages: | |
- stage: BuildSetup | |
displayName: Setup Build | |
jobs: | |
- job: BuildSetup | |
steps: | |
- task: PowerShell@2 | |
displayName: "Update Build Number" | |
inputs: | |
targetType: 'inline' | |
script: | | |
$BuildName = $env:BUILD_DEFINITIONNAME +'_'+$env:VERSIONNUMBER +'_'+ $env:BUILD_SOURCEBRANCHNAME -Replace ('-', '_') | |
Write-Host "##vso[build.updatebuildnumber]$BuildName" | |
- stage: Build | |
displayName: Build | |
dependsOn: BuildSetup | |
jobs: | |
- job: 'Build' | |
displayName: 'Build' | |
steps: | |
- task: UsePythonVersion@0 | |
inputs: | |
versionSpec: $(python_version) | |
addToPath: true | |
architecture: "x64" | |
displayName: "Use Python $(python_version)" | |
# - task: PythonScript@0 | |
# inputs: | |
# scriptSource: 'filePath' | |
# scriptPath: $(Build.SourcesDirectory)/alter_setup.py # write this script | |
# arguments: $(Version.Major) $(Version.Minor) $(Version.Revision) # read up on semver 2.0 | |
# displayName: "Generate setup.py" | |
# - task: PythonScript@0 | |
# inputs: | |
# scriptSource: 'filePath' | |
# scriptPath: $(Build.SourcesDirectory)/alter_init.py # write this script | |
# arguments: '{libname}-$(Version.Major).$(Version.Minor).$(Version.Revision)-none-any.whl' #change to lib name | |
# displayName: "Generate init.sh" | |
# - task: PythonScript@0 | |
# inputs: | |
# scriptSource: 'inline' | |
# script: | | |
# f = open ($(Build.SourcesDirectory)/{name_of_init_file}}.sh) | |
# file_contents = f.read() | |
# print(file_contents) | |
# f.close() | |
# displayName: "Write contents of init to console" | |
- script: | | |
echo 'insert code to create wheel here' | |
displayName: 'Create wheel artefact for pushing to PyPi' | |
- script: | | |
echo 'insert code to move generated init file to its own folder so we can create a publishbuildartifact@1 task' | |
displayName: 'Create init for pushing to dbfs' | |
# this is an exmaple of creating an artefact using the readme. | |
# you will need to create an artefact of the wheel | |
# what location is your compiled wheel built? | |
# you only want to create an artefact of the latest wheel: is your dist folder empty? | |
# is the dist folder listed in gitignore? | |
- task: PublishBuildArtifacts@1 | |
inputs: | |
PathtoPublish: '$(Build.SourcesDirectory)/README.md' | |
ArtifactName: 'wheel' | |
publishLocation: 'Container' | |
- stage: Deploy | |
displayName: Deploy | |
dependsOn: Build | |
jobs: | |
- job: 'Deploy' | |
displayName: 'Deploy' | |
steps: | |
- download: current | |
artifact: wheel | |
- script: | | |
pip install databricks-cli | |
echo 'install databricks-cli with pip' | |
displayName: 'install databricks-cli' | |
- script: | | |
echo 'configure databricks-cli with a databricks token you created and workspace url' | |
echo 'what is on the dbfs' | |
echo 'wheel stored in artefacts do not exist on dbfs' | |
databricks fs ls dbfs:/FileStore/richiebzzzt/ | |
displayName: 'files in artefact do not exist on dbfs' | |
- script: | | |
echo 'configure databricks-cli with a databricks token you created and workspace url' | |
echo 'how to create bearer tokens - https://docs.databricks.com/dev-tools/auth.html#id2' | |
echo 'bearer tokens are secrets; the values need to be stored securely... ie not hard-coded in the yaml' | |
echo 'https://learn.microsoft.com/en-us/azure/databricks/dev-tools/cli/#cli-auth' | |
echo 'finally use cli to upload artifact folders to dbfs' | |
displayName: 'upload files to Databricks' | |
- script: | | |
echo 'configure databricks-cli with a databricks token you created and workspace url' | |
echo 'what is on the dbfs' | |
echo 'wheel stored in artefacts exist on dbfs' | |
echo 'this is because previous step pushed them to location you have been using to upload them to manually' | |
databricks fs ls dbfs:/FileStore/richiebzzzt/ | |
displayName: 'files in artefact now exist on dbfs' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment