Continuous Integration¶
We use a so-called continuous integration workflow with TARDIS. This means that each time a change is proposed (via pull request) or a change is merged into the master branch, a service will clone the repository, checkout to the current commit and execute all the TARDIS tests. This helps us to detect bugs immediately.
GitHub Actions¶
A pipeline (or a workflow) is essentially a YAML configuration file with different sections such as variables, jobs and steps. These files run commands or tasks when they are triggered by some event, like a commit being pushed to a certain branch.
Currently, we use GitHub Actions to run all of our pipelines. Making changes to an existing
pipeline is as easy as making a pull request. To create a new GitHub Action workflow,
just create a new YAML file in .github/workflows.
TARDIS Pipelines¶
Brief description of pipelines already implemented on TARDIS
Cache Keys in TARDIS CI¶
TARDIS uses specific cache key formats to efficiently store and retrieve data during CI runs:
Regression Data Cache Keys - Format:
tardis-regression-<data-type>-<hash>-v1- Examples:tardis-regression-atom-data-sparse-<hash>-v1- For atomic data cachetardis-regression-full-data-<hash>-v1- For full TARDIS regression data cache
Used in:
setup_lfsaction
Environment Cache Keys - Format:
tardis-conda-env-<os-label>-<hash>-v1- Examples:tardis-conda-env-linux-<hash>-v1- For Linux conda environmenttardis-conda-env-macos-<hash>-v1- For macOS conda environment
Used in:
setup_envaction
Warning
The version suffix (-v1) allows for future cache invalidation if needed.
The
lfs-cacheworkflow will fail if the cache is not available and will not pull LFS data by default.However, if the
allow_lfs_pulllabel is added to the PR, the workflow will pull LFS data. Please note that this is to be used sparingly and only with caution.
Streamlined Steps for TARDIS Pipelines¶
We have a common set of steps which are utilized in TARDIS pipelines to streamline the process:
Common Steps¶
Use `setup_lfs` Action and `lfs-cache` workflow - If you need access to regression or atomic data, incorporate the
setup_lfsaction to ensure proper handling of large file storage. - Thelfs-cacheworkflow is used to cache the regression data and atomic data and to check if the cache is available.Use `setup_env` Action - To configure your environment effectively, utilize the
setup_envaction. This will help establish the necessary variables and settings for your pipeline.Run Configuration - Ensure that your pipeline runs with the appropriate shell settings. You can define this in your YAML configuration as follows:
defaults: run: shell: bash -l {0}
Documentation build pipeline¶
A GitHub Actions workflow that builds and deploys the TARDIS documentation website.
Documentation preview pipeline¶
This workflow does not run on the main repository, just on forks. See the Documentation Preview section for more information.
Testing pipeline¶
The testing pipeline (CI) comprises 4 concurrent jobs that execute tests both with and without the continuum marker across Ubuntu and macOS platforms (2 platforms × 2 test types). The pipeline includes both preparatory setup (environment installation and regression data configuration) and subsequent uploading of coverage reports upon test completion.
Note
GPU Tests can be triggered by applying the full-tests label to the pull request.
Release pipeline¶
Publishes a new release of TARDIS every Sunday at 00:00 UTC.
Pre-release¶
The pre-release action clones the tardis-sn/tardis_zenodo repository, runs the notebook to
generate a new .zenodo.json file, and pushes it to the root of the tardis repository.
This file is used to create a new version of TARDIS on Zenodo with all committers as authors.
A pull request is created and automatically merged if all required checks pass.
Checkout the
tardis-sn/tardis_zenodorepository.Wait for the Zenodo webhook to be available (3 min sleep).
Set up the Python environment stored in
tardis-sn/tardis_zenodo.Store the secret key for the Zenodo API in an environment variable.
Run the notebook to generate a new
.zenodo.jsonfile. Re-run if there are errors and ignore any errors.Upload the
.zenodo.jsonas an artifact.
Runs the TARDIS test suite after installing TARDIS using pip from master(using git) instead of editable install. This flags cases when a new modules was introduced recently without an __init__.py file or data files not included in [tool.setuptools.package-data] inside pyproject.toml.
Relies on Zenodo and pip test steps completing.
Checks out the TARDIS repository.
Downloads the artifacts from the previous steps.
Checks for
.zenodo.jsonand uses it if it was generated.Get the current date.
Create a bot pull request on the tardis-bot fork using a branch named
pre-release-<date>with the new.zenodo.jsonfile.Wait for the PR to be created (1 min sleep).
Automatically approve the PR using tokens from the infrastructure and core coordinator members.
Enable auto-merge.
Release¶
Creates a new release on GitHub after the pre-release PR is merged.
Check out the TARDIS repository with 0 fetch depth.
Set up Python.
Install
setuptools_scmandgit-cliff.Get the current TARDIS version using
setuptools_scmvia a helper script.Get the next TARDIS version using
setuptools_scm.Create a GitHub release that uses the new version as the tag.
Wait for Zenodo to update the new release of TARDIS (2 min sleep).
Fetch the new DOI from Zenodo using the Zenodo API, and create a badge.
Generate the changelog using
git-cliff.Update the release description with the changelog and the Zenodo badge. Include the environment lock files in the release assets.
Post-release¶
The post-release action updates the changelog, citation and credits in the main repository.
Check out the TARDIS repository with 0 fetch depth.
Get the current release tag
Generate a changelog with
git-cliffUpload a CHANGELOG.md file as an artifact.
Check out the TARDIS repository.
Wait for the Zenodo webhook to be available (3 min sleep).
Set up Python.
Install
doi2cff.Convert the latest TARDIS release DOI to a CITATION.cff file. Try 10 times with a 60 second sleep between attempts.
Upload the CITATION.cff file as an artifact.
Check out the TARDIS repository.
Wait for the Zenodo webhook to be available (3 min sleep).
Set up Python.
Install
requests.Run a helper script to update
README.rstanddocs/resources/credits.rst.Upload README.rst and credits.rst as artifacts.
Dispatch the updates to the TARDIS website.
Checks out the TARDIS repository.
Downloads the artifacts from the previous steps.
Copy the
CHANGELOG.md,CITATION.cff,README.rstandcredits.rstfiles to the repository.Get the current date.
Create a pull request.
Wait for the PR to be created (30 second sleep).
Automatically approve the PR using tokens from the infrastructure and core coordinator members.
Enable auto-merge.
TARDIS Carsus Compatibility Check¶
The TARDIS Carsus Compatibility Check or the “Bridge” compares reference data
generated with different versions of Carsus. It consists of two jobs- a “carsus-build” job to
generate an atomic file with the latest version of Carsus and a “tardis-build” job
to generate a new reference data with it. These two reference data files are compared using the
this notebook.
The workflow has a workflow_dispatch event so that it can be triggered manually, but is also
triggered every week due to the “save-atomic-files” workflow.
The Save Atomic Files Workflow¶
The Save Atomic Files workflow runs every week but can also be triggered manually. It runs the “Bridge” and sends an artifact containing the generated atomic data file and the comparison notebook to Moria. This workflow has a separate job to indicate if the bridge has failed.
The Regression Data Comparison Workflow¶
The Regression Data Comparison workflow compares the regression data between the current branch and the base branch on pull requests. It only runs on pull requests and not on the master branch. The workflow generates regression data for the latest commit on the pull request and compares it with the master branch using the comparison notebook. The notebook is then uploaded as an artifact and pushed to reg-data-comp repository for previews in the bot comment.
Note
The workflow exports images from the comparison notebook and embeds them in the bot comment. Unless there are any key changes to any of the HDF files in the regression data the bot will only show two images, one containing the spectrum change and another containing relative changes in the keys. If there are any key changes, the bot will show three images, the additional one visualizing the key changes.
The LFS-cache workflow¶
The LFS-cache workflow caches the regression data and atomic data and can be triggered either manually or when there is a push to the main branch of the regression data repository. This is mainly responsible for doing LFS pulls when necessary and caching objects while the setup-lfs action is used to restore the cached objects. Both fail if the cache is not available.