Skip to content

return raw MF results #227

return raw MF results

return raw MF results #227

name: Tests
# Define when to run
on:
schedule:
- cron: '30 4 1 * *'
push:
branches:
- development
pull_request:
branches:
- development
# Env variables
env:
CACHE_NUMBER: 0 # increase to reset cache manually
# Jobs
jobs:
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
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:
# 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@v3
# setup the conda env
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: zen-garden-linopy
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
- name: Create Coverage Badge
if: ${{ always() && matrix.label == 'linux-64' && github.event_name == 'push' }}
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.COVERAGE_SECRET }}
gistID: 5d0d79e86182cd9ccd785d824b1f9ac7
filename: zen_coverage.json
label: Coverage
message: ${{ env.COVERAGE_FLT }}%
valColorRange: ${{ env.COVERAGE_INT }}
maxColorRange: 100
minColorRange: 0
# Auto pull request into master if build succeeds
auto_pr:
name: Auto PR
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
with:
ref: development
fetch-depth: 0
- name: Pull Request develop -> main
uses: devops-infra/action-pull-request@v0.5.3
with:
github_token: ${{ github.token }}
target_branch: main
title: "AUTO PR"
body: "**This is an automated pull request triggered by successfull tests of the dev branch!**"
label: 'automated pr'