Skip to content

Commit

Permalink
Add separate job to check lfs
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Jan 27, 2025
1 parent 20ba404 commit 1543d04
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
18 changes: 2 additions & 16 deletions .github/actions/setup_lfs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,14 @@ runs:
fi
working-directory: tardis-regression-data
shell: bash

- name: Initial LFS cache restore attempt
uses: actions/cache/restore@v4
id: lfs-cache-regression-data
with:
path: tardis-regression-data/.git/lfs
key: tardis-regression-${{ inputs.atom-data-sparse == 'true' && 'atom-data-sparse' || 'full-data' }}-${{ hashFiles('tardis-regression-data/.lfs-files-list') }}-${{ inputs.regression-data-repo }}-v1

- name: Download and cache LFS files if cache miss
uses: atharva-2001/tardis/.github/workflows/lfs-cache.yml@fix_lfs
if: steps.lfs-cache-regression-data.outputs.cache-hit != 'true'
with:
atom-data-sparse: ${{ inputs.atom-data-sparse }}
regression-data-repo: ${{ inputs.regression-data-repo }}
lfs-files-list: tardis-regression-data/.lfs-files-list

- name: Restore newly created LFS cache
- name: Restore LFS cache
uses: actions/cache/restore@v4
id: lfs-cache-regression-data-final
with:
path: tardis-regression-data/.git/lfs
key: tardis-regression-${{ inputs.atom-data-sparse == 'true' && 'atom-data-sparse' || 'full-data' }}-${{ hashFiles('tardis-regression-data/.lfs-files-list') }}-${{ inputs.regression-data-repo }}-v1
fail-on-cache-miss: true

- name: Git LFS Checkout
run: git lfs checkout
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ defaults:
shell: bash -l {0}

jobs:
test_cache:
uses: ./.github/workflows/lfs-cache.yml
with:
atom-data-sparse: false
regression-data-repo: tardis-sn/tardis-regression-data

build:
if: github.repository_owner == 'tardis-sn' &&
(github.event_name == 'push' ||
Expand All @@ -37,6 +43,7 @@ jobs:
(github.event_name == 'pull_request_target' &&
contains(github.event.pull_request.labels.*.name, 'benchmarks')))
runs-on: ubuntu-latest
needs: [test_cache]
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ defaults:
shell: bash -l {0}

jobs:
test_cache:
uses: ./.github/workflows/lfs-cache.yml
with:
atom-data-sparse: true
regression-data-repo: tardis-sn/tardis-regression-data

check-for-changes:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
Expand Down Expand Up @@ -77,7 +83,7 @@ jobs:

build-docs:
runs-on: ubuntu-latest
needs: check-for-changes
needs: [test_cache, check-for-changes]
if: needs.check-for-changes.outputs.trigger-check-outcome == 'success' || needs.check-for-changes.outputs.docs-check-outcome == 'success'
steps:
- uses: actions/checkout@v4
Expand All @@ -90,13 +96,10 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
if: github.event_name == 'pull_request_target'

- uses: actions/checkout@v4
- name: Setup LFS
uses: ./.github/actions/setup_lfs
with:
repository: tardis-sn/tardis-regression-data
path: tardis-regression-data
lfs: true
sparse-checkout: |
atom_data/kurucz_cd23_chianti_H_He.h5
atom-data-sparse: true

- name: Setup environment
uses: ./.github/actions/setup_env
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/lfs-cache.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Save LFS Cache

on:
workflow_dispatch:
workflow_call:
inputs:
atom-data-sparse:
Expand Down Expand Up @@ -46,15 +45,23 @@ jobs:
echo ${{ inputs.atom-data-sparse }}
echo ${{ inputs.regression-data-repo }}
- name: Test cache availability
uses: actions/cache/restore@v4
id: test-lfs-cache-regression-data
with:
path: tardis-regression-data/.git/lfs
key: tardis-regression-${{ inputs.atom-data-sparse == 'true' && 'atom-data-sparse' || 'full-data' }}-${{ hashFiles('tardis-regression-data/.lfs-files-list') }}-${{ inputs.regression-data-repo }}-v1
lookup-only: true

- name: Git LFS Pull Atom Data
run: git lfs pull --include-ref=atom_data/kurucz_cd23_chianti_H_He.h5
if: ${{ inputs.atom-data-sparse == 'true' }}
if: ${{ inputs.atom-data-sparse == 'true' && steps.test-lfs-cache-regression-data.outputs.cache-hit != 'true' }}
working-directory: tardis-regression-data
shell: bash

- name: Git LFS Pull Full Data
run: git lfs pull
if: ${{ inputs.atom-data-sparse == 'false' }}
if: ${{ inputs.atom-data-sparse == 'false' && steps.test-lfs-cache-regression-data.outputs.cache-hit != 'true' }}
working-directory: tardis-regression-data
shell: bash

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ concurrency:
cancel-in-progress: true

jobs:
test_cache:
uses: ./.github/workflows/lfs-cache.yml
with:
atom-data-sparse: false
regression-data-repo: tardis-sn/tardis-regression-data

tests:
name: ${{ matrix.continuum }} continuum ${{ matrix.os }} ${{ inputs.pip_git && 'pip tests enabled' || '' }}
if: github.repository_owner == 'tardis-sn'
needs: [test_cache]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down

0 comments on commit 1543d04

Please sign in to comment.