Skip to content

Commit

Permalink
Experimental setup
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Jul 12, 2024
1 parent b469c23 commit d029d4a
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 79 deletions.
127 changes: 127 additions & 0 deletions .github/actions/setup_tardis/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: "Setup TARDIS"
description: "Sets up regression/refdata and environment"

inputs:
os-label:
description: "os label for lock file, default linux"
required: true
default: "linux"
refdata-repo:
description: "tardis refdata repository"
required: false
default: "tardis-sn/tardis-refdata"
regression-data-repo:
description: "tardis regression data repository"
required: false
default: "tardis-sn/tardis-regression-data"

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- name: Clone Refdata Repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.refdata-repo }}
path: tardis-refdata
lfs: false

- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
working-directory: tardis-refdata
shell: bash

- name: Restore LFS cache
uses: actions/cache/restore@v4
id: lfs-cache-refdata
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-refdata.outputs.cache-hit != 'true'
shell: bash

- name: Git LFS Checkout
run: git lfs checkout
working-directory: tardis-refdata
if: steps.lfs-cache-refdata.outputs.cache-hit == 'true'
shell: bash

- 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-refdata.outputs.cache-hit != 'true' && always() || false }}
uses: actions/cache/save@v4
id: lfs-cache-refdata-save
with:
path: tardis-refdata/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1

- name: Clone tardis-sn/tardis-regression-data
uses: actions/checkout@v4
with:
repository: ${{ inputs.regression-data-repo }}
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
shell: bash

- name: Restore LFS cache
uses: actions/cache/restore@v4
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'
shell: bash

- name: Git LFS Checkout
run: git lfs checkout
working-directory: tardis-regression-data
if: steps.lfs-cache-regression-data.outputs.cache-hit == 'true'
shell: bash

- 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@v4
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: Download Lock File
run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-${{ inputs.os-label }}.lock
if: matrix.pip == true
shell: bash

- name: Generate Cache Key
run: |
file_hash=$(cat conda-${{ inputs.os-label }}.lock | shasum -a 256 | cut -d' ' -f1)
echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}"
id: cache-environment-key
shell: bash

- uses: mamba-org/setup-micromamba@v1
with:
environment-file: conda-${{ inputs.os-label }}.lock
cache-environment-key: ${{ steps.cache-environment-key.outputs.file_hash }}
cache-downloads-key: ${{ steps.cache-environment-key.outputs.file_hash }}
environment-name: tardis
cache-environment: true
cache-downloads: true

- name: Install package editable
shell: bash
run: |
pip install -e .
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: main

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
matrix:
if: github.repository_owner == 'tardis-sn'
strategy:
# super important if you want to see all results, even if one fails
# fail-fast is true by default
fail-fast: false
matrix:
label: [osx-arm64, linux-64]
include:
- label: osx-arm64
os: macos-latest
prefix: /Users/runner/miniconda3/envs/tardis

- label: linux-64
os: ubuntu-latest
prefix: /usr/share/miniconda3/envs/tardis

uses: ./.github/workflows/new_tests.yml # calls the one above ^
with:
run_label: ${{ matrix.label }}
secrets: inherit
108 changes: 29 additions & 79 deletions .github/workflows/new_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
name: tests

on:
push:
branches:
- '*'

pull_request:
branches:
- '*'
workflow_call:
inputs:
run_label:
required: true
type: string

# push:
# branches:
# - '*'

# pull_request:
# branches:
# - '*'

types:
- opened
- reopened
- synchronize
- labeled
# types:
# - opened
# - reopened
# - synchronize
# - labeled

env:
CACHE_NUMBER: 0 # increase to reset cache manually
Expand All @@ -36,90 +42,34 @@ defaults:


jobs:
build:
non-continuum:
if: github.repository_owner == 'tardis-sn'
strategy:
matrix:
label: [osx-arm64, linux-64]
include:
- label: osx-arm64
os: macos-latest
prefix: /Users/runner/miniconda3/envs/tardis

- label: linux-64
os: ubuntu-latest
prefix: /usr/share/miniconda3/envs/tardis

name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
name: non-continuum-${{ inputs.run_label }}
runs-on: ${{ inputs.run_label }}
steps:
- uses: actions/checkout@v4
- name: Setup tardis
uses: ./.github/actions/setup_tardis

- name: Setup LFS
uses: ./.github/actions/setup_lfs

- name: Setup environment
uses: ./.github/actions/setup_env
with:
os-label: ${{ matrix.label }}

- name: Install package editable
run: |
pip install -e .
- name: Run continuum tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m continuum
- name: Run tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "not continuum"
if: always()

- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)

- name: Refdata Generation tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference
if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master'

continuum_tests:
if: github.repository_owner == 'tardis-sn'
strategy:
matrix:
label: [osx-arm64, linux-64]
include:
- label: osx-arm64
os: macos-latest
prefix: /Users/runner/miniconda3/envs/tardis

- label: linux-64
os: ubuntu-latest
prefix: /usr/share/miniconda3/envs/tardis

name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
name: ${{ inputs.run_label }}
runs-on: ${{ inputs.run_label }}
steps:
- uses: actions/checkout@v4

- name: Setup LFS
uses: ./.github/actions/setup_lfs

- name: Setup environment
uses: ./.github/actions/setup_env
with:
os-label: ${{ matrix.label }}

- name: Install package editable
run: |
pip install -e .
- name: Run tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "not continuum"
if: always()
- name: Setup tardis
uses: ./.github/actions/setup_tardis

- name: Run continuum tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m continuum
if: always()

- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)

- name: Refdata Generation tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference
if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master'

0 comments on commit d029d4a

Please sign in to comment.