From 156898a5ab2511c522a7ae63c0788fea46c409fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20P=C3=A1ssaro?= Date: Wed, 14 Oct 2020 12:55:36 -0300 Subject: [PATCH] Apply new template to refdata pipeline (#1310) * Initial commit * Remove extra condition * Enable pr trigger * disable debug flag * try comment trigger * do not use mamba * use mamba. use pytest instead of setup.py * try run notebook * set upstream remote * remove condition * pin nbconvert * pin nbconvert * minor changes * unpin nbconvert * use https repo again * add extra packages parameter to template * try extra packages parameter * remove extra packages parameter, changes to step names * add monthly cron trigger * update docs --- azure-pipelines/compare-refdata.yml | 81 +++++++++------------ azure-pipelines/templates/default.yml | 32 ++++---- docs/development/continuous_integration.rst | 19 +++-- 3 files changed, 65 insertions(+), 67 deletions(-) diff --git a/azure-pipelines/compare-refdata.yml b/azure-pipelines/compare-refdata.yml index 749d2ce719b..912e3a68ca9 100644 --- a/azure-pipelines/compare-refdata.yml +++ b/azure-pipelines/compare-refdata.yml @@ -1,73 +1,64 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml +# For more information on how to use this pipeline please refer to: +# http://tardis-sn.github.io/tardis/development/continuous_integration.html trigger: none -pr: none +pr: [ master ] + +schedules: + - cron: '0 0 1 * *' + displayName: 'Monthly test' + branches: + include: + - master variables: - system.debug: "true" - ref.data.home: "$(Agent.BuildDirectory)/tardis-refdata" - ref.data.github.url: "https://github.com/tardis-sn/tardis-refdata.git" - tardis.build.dir: $(Build.Repository.LocalPath) + system.debug: false jobs: - job: report pool: - vmImage: "ubuntu-latest" + vmImage: 'ubuntu-latest' steps: - - bash: | - echo "##vso[task.prependpath]$CONDA/bin" - sudo chown -R $USER $CONDA - displayName: "Add CONDA to path" - - - bash: | - sh ci-helpers/install_tardis_env.sh - displayName: "Install TARDIS env" - + - template: templates/default.yml + parameters: + fetchRefdata: true + useMamba: true + - bash: | source activate tardis - conda install bokeh -c conda-forge --no-update-deps --yes - displayName: "Install Bokeh" + $(package.manager) install bokeh --channel conda-forge --no-update-deps --yes + displayName: 'Install Bokeh' - bash: | - source activate tardis - git clone https://github.com/tardis-sn/tardis-refdata.git $(ref.data.home) - displayName: "Fetch ALL reference data" + cd $(refdata.dir) + git remote add upstream https://tardis-sn@dev.azure.com/tardis-sn/TARDIS/_git/tardis-refdata + git fetch upstream + git fetch upstream "+refs/pull/*/head:refs/remotes/upstream/pr/*" + displayName: 'Set upstream remote' - bash: | + cd $(tardis.dir) source activate tardis - python setup.py build_ext --inplace - displayName: "Build & install TARDIS" + pytest tardis --tardis-refdata=$(refdata.dir) --generate-reference + displayName: 'Generate reference data' - bash: | + cd $(refdata.dir)/notebooks source activate tardis - python setup.py test --args="--tardis-refdata=$(ref.data.home) --generate-reference" - displayName: "Generate new reference data" + jupyter nbconvert ref_data_compare.ipynb --to html --execute --ExecutePreprocessor.timeout=6000 + displayName: 'Render notebook' - bash: | + cd $(refdata.dir)/notebooks source activate tardis - cd $(ref.data.home) - git remote add upstream https://github.com/tardis-sn/tardis-refdata.git - git fetch upstream - git fetch upstream "+refs/pull/*/head:refs/remotes/upstream/pr/*" - cd notebooks jupyter nbconvert ref_data_compare.ipynb --to html --execute --allow-errors --ExecutePreprocessor.timeout=6000 - displayName: "Generating report" + displayName: 'Render notebook (allow errors)' + condition: failed() - task: PublishPipelineArtifact@1 inputs: - targetPath: "$(ref.data.home)/notebooks/ref_data_compare.html" - artifact: "report" - publishLocation: "pipeline" - - - bash: | - ls -lR /tmp - echo + targetPath: '$(refdata.dir)/notebooks/ref_data_compare.html' + artifactName: 'report' + displayName: 'Upload artifact' condition: succeededOrFailed() - displayName: "Check files in /tmp" - -# Keep this line, is useful for testing without changing the notebook. -# sed -i "s/ref2_hash='upstream\/pr\/24'/ref1_hash='c998f44', ref2_hash='master'/g" ref_data_compare.ipynb \ No newline at end of file diff --git a/azure-pipelines/templates/default.yml b/azure-pipelines/templates/default.yml index 1620afb32bf..8ce061f352f 100644 --- a/azure-pipelines/templates/default.yml +++ b/azure-pipelines/templates/default.yml @@ -16,45 +16,49 @@ parameters: steps: - bash: echo "##vso[task.setvariable variable=shellopts]errexit" - displayName: 'Force BASH exit if a command exits with non-zero status' + displayName: 'Set BASH exit on error' condition: eq(variables['Agent.OS'], 'Linux') - bash: | echo "##vso[task.setvariable variable=sources.dir]$(Build.SourcesDirectory)" echo "##vso[task.setvariable variable=tardis.dir]$(Build.SourcesDirectory)/tardis" echo "##vso[task.setvariable variable=refdata.dir]$(Build.SourcesDirectory)/tardis-refdata" - displayName: 'Set custom variables' + displayName: 'Set source directories' + + - ${{ if eq(parameters.useMamba, false) }}: + - bash: | + echo "##vso[task.setvariable variable=package.manager]conda" + displayName: 'Set package manager' + + - ${{ if eq(parameters.useMamba, true) }}: + - bash: | + echo "##vso[task.setvariable variable=package.manager]mamba" + displayName: 'Set package manager' - checkout: self - displayName: 'Fetch TARDIS repository (GitHub)' + displayName: 'Fetch TARDIS repository from GitHub' - ${{ if eq(parameters.fetchRefdata, true) }}: - checkout: git://TARDIS/tardis-refdata lfs: true - displayName: 'Fetch reference data repository (Azure Repos)' + displayName: 'Fetch reference data repository from Azure Repos' - bash: echo "##vso[task.prependpath]$CONDA/bin" displayName: 'Add conda to PATH' - bash: sudo chown -R $USER $CONDA - displayName: 'Take ownership of conda installation (macOS)' + displayName: 'Take ownership of conda installation' condition: eq(variables['Agent.OS'], 'Darwin') - ${{ if eq(parameters.useMamba, true) }}: - bash: conda install mamba -c conda-forge -y displayName: 'Install Mamba package manager' - - ${{ if and( eq(parameters.skipInstall, false), eq(parameters.useMamba, false)) }}: - - bash: | - cd $(tardis.dir) - conda env create -f tardis_env3.yml - displayName: 'TARDIS environment install (conda)' - - - ${{ if and( eq(parameters.skipInstall, false), eq(parameters.useMamba, true)) }}: + - ${{ if eq(parameters.skipInstall, false) }}: - bash: | cd $(tardis.dir) - mamba env create -f tardis_env3.yml - displayName: 'TARDIS environment install (mamba)' + $(package.manager) env create -f tardis_env3.yml + displayName: 'TARDIS environment install' - ${{ if eq(parameters.skipInstall, false) }}: - bash: | diff --git a/docs/development/continuous_integration.rst b/docs/development/continuous_integration.rst index 51e2a150e52..2bfd74c5748 100644 --- a/docs/development/continuous_integration.rst +++ b/docs/development/continuous_integration.rst @@ -290,11 +290,14 @@ Publishes a new release of TARDIS every sunday at 00:00 UTC. Reference data pipeline ----------------------- -Generates new reference data according to changes present in the pull -request. Then, compares against reference data from the head of the -*master* branch in ``tardis-refdata`` repository by running a -notebook. Finally, uploads the rendered notebook to the pipeline -results. - -.. note:: This pipeline runs manually (from the Azure web UI) or by - enabling the PR trigger via pull request. \ No newline at end of file +Generates new reference data according to the changes present in the +current pull request. Then, compares against reference data present in the +head of ``tardis-refdata`` repository by running a notebook. Finally, uploads +the rendered notebook to the pipeline results. + +To trigger this pipeline is necessary to leave a comment in the GitHub pull +request. +:: + /AzurePipelines run TARDIS refdata + +For brevity, you can comment using ``/azp`` instead of ``/AzurePipelines``. \ No newline at end of file