Skip to content

Updated CLI Arguments for visualizations #660

Updated CLI Arguments for visualizations

Updated CLI Arguments for visualizations #660

name: Tests
# Define when to run
on:
schedule:
- cron: '30 4 1 * *'
push:
branches:
- main
pull_request:
branches: ['*']
# Env variables
env:
CACHE_NUMBER: 0 # increase to reset cache manually
# Jobs
jobs:
check_skiptests:
runs-on: ubuntu-latest
outputs:
skiptests: ${{ steps.check_commit.outputs.skiptests }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for '#skiptests' in commit messages
id: check_commit
run: |
commit_message="${{ github.event.head_commit.message }}"
if [[ "$commit_message" =~ "#skiptests" ]]; then
skip="true"
else
skip="false"
fi
echo "skiptests=$skip" >> $GITHUB_ENV
echo "skiptests=$skip" >> $GITHUB_OUTPUT
echo "skiptests=$skip"
matrix_prep:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' }}
needs: check_skiptests
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Env File
id: check-env-file
uses: tj-actions/changed-files@v41
with:
files: |
zen_garden_env.yml
- name: Set Env
# trigger if env file change or on schedule
if: ${{ steps.check-env-file.outputs.any_changed == 'true' || github.event_name == 'schedule' }}
run: echo "ENV_STATE=env_change" >> $GITHUB_ENV
- id: set-matrix
uses: JoshuaTheMiller/conditional-build-matrix@main
with:
# Run filter -> see matrix_includes.json!
filter: '[?runs_when==`${{ env.ENV_STATE }}` || runs_when==`${{ github.event_name }}` || runs_when==`always`]'
build:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' }}
# the testing
needs: matrix_prep
strategy:
fail-fast: false # if true all jobs are cancelled if one fails
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
# checkout the dev branch
- uses: actions/checkout@v4
# setup the conda env
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: zen-garden
use-mamba: true
# date for the cache
- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
# reset cache if env file changed
- uses: actions/cache@v3
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('zen_garden_env.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
# This step is cached in case the env file was not changed
- name: Update environment
run: mamba env update -f zen_garden_env.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Install package
shell: bash -l {0}
run: pip install -e .
- name: Run Tests
shell: bash -l {0}
run: |
coverage run --source="zen_garden" -m pytest -v tests/testcases/run_test.py
coverage report -m
- name: Extract Coverage
if: ${{ always() && matrix.label == 'linux-64' && github.event_name == 'push' }} # include always to overwrite cancel on failure of previous step
shell: bash -l {0}
run: |
echo "COVERAGE_INT=$(coverage report -m | grep TOTAL | grep -oE '[0-9]+%' | grep -oE '[0-9]+')" >> $GITHUB_ENV
echo "COVERAGE_FLT=$(coverage report -m --precision=2 | grep TOTAL | grep -oE '[0-9]+\.[0-9]+')" >> $GITHUB_ENV
# COMMENTED OUT BECAUSE THIS LEAD TO A 400 Bad request ERROR
- name: Create Coverage Badge
if: ${{ always() && matrix.label == 'linux-64' && github.event_name == 'push' }}
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 30d479a5b4c591a63b7b0f41abbce6a0
filename: zen_garden_coverage.json
label: coverage
message: ${{ env.COVERAGE_FLT }}%
valColorRange: ${{ env.COVERAGE_INT }}
maxColorRange: 100
minColorRange: 0
#
bump_version:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Bump version and push tag
uses: jasonamyers/github-bumpversion-action@v1.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push changes
if: env.bump != 'none'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true
release:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: "Create Github Release"
needs: bump_version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get-latest-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Extract tag version
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
with:
semver_only: true
- name: Check for major/minor version
id: check_version
run: |
TAG=${{ steps.get-latest-tag.outputs.tag }}
PATCH_VERSION=$(echo $TAG | cut -d. -f3)
echo "patch=$PATCH_VERSION"
echo "patch=$PATCH_VERSION" >> $GITHUB_ENV
echo "tag=$tag" >> $GITHUB_OUTPUT
if [[ $PATCH_VERSION -eq 0 ]]; then
echo "is_major_minor=true" >> $GITHUB_ENV
else
echo "is_major_minor=false" >> $GITHUB_ENV
fi
- name: Create GitHub Release
if: env.is_major_minor == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-latest-tag.outputs.tag }}
release_name: Release ${{ steps.get-latest-tag.outputs.tag }}
body: "Automated release for version ${{ steps.get-latest-tag.outputs.tag }} after major/minor version bump."
draft: false
prerelease: false
build-package:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' }}
name: "Build and verify package"
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}
- uses: hynek/build-and-inspect-python-package@v2
#
# release-test-pypi:
# if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' }}
# name: "Release to Test PyPI"
# runs-on: ubuntu-latest
# needs: build-package
# environment:
# name: test-pypi
# url: https://test.pypi.org/project/zen-garden/
# permissions:
# id-token: write
# steps:
# - name: Download packages
# uses: actions/download-artifact@v4
# with:
# name: Packages
# path: dist
#
# - name: Publish to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
release-pypi:
if: ${{ github.repository == 'ZEN-universe/ZEN-garden' && needs.check_skiptests.outputs.skiptests == 'false' }}
name: "Release to PyPI"
runs-on: ubuntu-latest
needs: build-package
environment:
name: pypi
url: https://pypi.org/project/zen-garden/
permissions:
id-token: write
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1