diff --git a/.github/actions/setup_tardis/action.yml b/.github/actions/setup_tardis/action.yml new file mode 100644 index 00000000000..dd862868dc8 --- /dev/null +++ b/.github/actions/setup_tardis/action.yml @@ -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 . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..1be645b9122 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/new_tests.yml b/.github/workflows/new_tests.yml index da773dba380..ada7a9349e7 100644 --- a/.github/workflows/new_tests.yml +++ b/.github/workflows/new_tests.yml @@ -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 @@ -36,43 +42,17 @@ 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 @@ -80,46 +60,16 @@ jobs: 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'