Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply new template to refdata pipeline #1310

Merged
merged 20 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 36 additions & 45 deletions azure-pipelines/compare-refdata.yml
Original file line number Diff line number Diff line change
@@ -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://[email protected]/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
32 changes: 18 additions & 14 deletions azure-pipelines/templates/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
19 changes: 11 additions & 8 deletions docs/development/continuous_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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``.