Skip to content

Merge pull request #205 from ETSInitiative/ci-noisy-fail #483

Merge pull request #205 from ETSInitiative/ci-noisy-fail

Merge pull request #205 from ETSInitiative/ci-noisy-fail #483

Workflow file for this run

name: CI
on:
push:
branches: [main]
tags: ['v**']
paths-ignore:
- '**/*.md'
pull_request: {branches: [main]}
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: 'false'
defaults: {run: {shell: 'bash -el {0}'}} # https://github.com/marketplace/actions/setup-miniconda#important
env:
YARDL_VERSION: 0.6.7
jobs:
validate:
strategy:
matrix:
cppVersion: [17]
environment: pypi
permissions: {id-token: write}
name: Validate Python and C++${{ matrix.cppVersion }} and deploy to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with: {fetch-depth: 0, submodules: recursive}
- name: strip environment.yml
run: |
cat environment.yml | grep -v "#.*\<\local\>" > temp-ci-environment.yml
- uses: conda-incubator/setup-miniconda@v4
with:
activate-environment: yardl
environment-file: temp-ci-environment.yml
- name: Install yardl
run: |
rm temp-ci-environment.yml
gh release download -R microsoft/yardl -p '*linux_x86_64.tar.gz' v$YARDL_VERSION
mkdir yardl
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" -C yardl
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
echo "$PWD/yardl" >> "$GITHUB_PATH"
env:
GH_TOKEN: ${{ github.token }}
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session if triggered
#if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled != 'false' }}
- name: Build model
run: just generate
- name: Run Python
run: just run-python
- name: Build cpp
run: |
export HDF5_ROOT="$CONDA_PREFIX"
just cmake_install_prefix="$PWD/cpp/install" build-cpp
echo CMAKE_PREFIX_PATH="$PWD/cpp/install" >> $GITHUB_ENV
- name: Run cpp
run: just run-cpp
- name: Build cpp example
run: |
just cmake_source_dir=ccp/example cmake_build_dir=cpp/example/build build-cpp
- id: prep
name: Prepare deployment
run: |
cp LICENSE.txt python/LICENSE
cp LICENSE.txt cpp/install/LICENSE
[[ "${GITHUB_REF}" == refs/tags/* ]] && tag="${GITHUB_REF#refs/tags/}" || tag=$(python -c 'import importlib.metadata as m; print(m.version("petsird"))')
tgz="petsird_${tag}_linux_x86_64.tar.gz"
tar -czf "$tgz" -C cpp/install .
echo tgz="$tgz" >> $GITHUB_OUTPUT
- id: dist
uses: casperdcl/deploy-pypi@v3
with:
build: python -o dist
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
name: gh release create --draft
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create --draft --title "$tag" --generate-notes "$tag" dist/${{ steps.dist.outputs.whl }} ${{ steps.prep.outputs.tgz }}
- uses: actions/upload-artifact@v7
with:
name: python-petsird
path: dist/**
- uses: actions/upload-artifact@v7
with:
name: cpp-petsird
path: cpp/install/**