compare-refdata-command #58
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
name: compare-refdata | |
on: | |
repository_dispatch: | |
types: [compare-refdata-command] | |
workflow_dispatch: | |
workflow_call: # to be called by pre release workflow | |
env: | |
PYTEST_FLAGS_COMPARE: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data --generate-reference | |
REF2_HASH: origin/master | |
defaults: | |
run: | |
shell: bash -l {0} | |
jobs: | |
build: | |
if: github.repository_owner == 'tardis-sn' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone tardis-sn/tardis-regression-data | |
uses: actions/checkout@v4 | |
with: | |
repository: tardis-sn/tardis-regression-data | |
path: tardis-regression-data | |
- name: Create LFS file list | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
working-directory: tardis-regression-data | |
- name: Restore LFS cache | |
uses: actions/cache/restore@v3 | |
id: lfs-cache-regression-data | |
with: | |
path: tardis-regression-data/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-regression-data/.lfs-assets-id') }}-v1 | |
- name: Git LFS Pull | |
run: git lfs pull | |
working-directory: tardis-regression-data | |
if: steps.lfs-cache-regression-data.outputs.cache-hit != 'true' | |
- name: Git LFS Checkout | |
run: git lfs checkout | |
working-directory: tardis-regression-data | |
if: steps.lfs-cache-regression-data.outputs.cache-hit == 'true' | |
- name: Save LFS cache if not found | |
# uses fake ternary | |
# for reference: https://github.com/orgs/community/discussions/26738#discussioncomment-3253176 | |
if: ${{ steps.lfs-cache-regression-data.outputs.cache-hit != 'true' && always() || false }} | |
uses: actions/cache/save@v3 | |
id: lfs-cache-regression-data-save | |
with: | |
path: tardis-regression-data/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-regression-data/.lfs-assets-id') }}-v1 | |
- name: Checkout TARDIS refdata | |
uses: actions/checkout@v4 | |
with: | |
path: tardis-refdata/ | |
lfs: false | |
ref: master | |
- name: Create LFS file list | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
working-directory: tardis-refdata | |
- name: Restore LFS cache | |
uses: actions/cache/restore@v3 | |
id: lfs-cache | |
with: | |
path: tardis-refdata/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1 | |
- name: Git LFS Pull | |
run: git lfs pull | |
working-directory: tardis-refdata | |
if: steps.lfs-cache.outputs.cache-hit != 'true' | |
- name: Git LFS Checkout | |
run: git lfs checkout | |
working-directory: tardis-refdata | |
if: steps.lfs-cache.outputs.cache-hit == 'true' | |
- name: Save LFS cache if not found | |
# uses fake ternary | |
# for reference: https://github.com/orgs/community/discussions/26738#discussioncomment-3253176 | |
if: ${{ steps.lfs-cache.outputs.cache-hit != 'true' && always() || false }} | |
uses: actions/cache/save@v3 | |
id: lfs-cache-save | |
with: | |
path: tardis-refdata/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1 | |
- name: Checkout TARDIS (master) | |
uses: actions/checkout@v4 | |
if: ${{ (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule') }} # for checking master | |
with: | |
repository: tardis-sn/tardis | |
path: tardis/ | |
- name: Checkout TARDIS (PR) | |
uses: actions/checkout@v4 | |
if: ${{ (github.event_name == 'repository_dispatch') }} # for checking PRs | |
with: | |
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} | |
path: tardis/ | |
ref: ${{ github.event.client_payload.pull_request.head.ref }} | |
- name: Setup environment | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: tardis | |
use-mamba: true | |
- name: Update environment | |
working-directory: tardis/ | |
run: mamba update -n tardis --file conda-linux-64.lock | |
- name: Install Bokeh | |
run: mamba install bokeh --channel conda-forge --no-update-deps --yes | |
- name: Generate reference data for comparison | |
working-directory: tardis/ | |
run: pytest tardis ${{ env.PYTEST_FLAGS_COMPARE }} | |
- name: Compare Reference Data | |
working-directory: tardis-refdata/notebooks/ | |
run: | | |
jupyter nbconvert ref_data_compare.ipynb --to html --allow-errors --execute --ExecutePreprocessor.timeout=6000 | |
- name: Upload comparison notebook | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Comparison Notebook | |
path: tardis-refdata/notebooks/ref_data_compare.html | |
- name: Check if reference data are equal | |
run: if [ "$(cat ../refdata_compare_result)" == "REFDATA COMPARISON FAILED" ]; then exit 1; fi | |