From eb940adcf6a49c7754bd2c2308a2381246c498af Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 29 Oct 2024 01:05:37 +0000 Subject: [PATCH] CI: fixup actions --- .../actions/configure-environment/action.yml | 23 +++-- .github/workflows/ci.yml | 91 +++++++++---------- .github/workflows/test_pypi.yml | 48 ---------- 3 files changed, 55 insertions(+), 107 deletions(-) delete mode 100644 .github/workflows/test_pypi.yml diff --git a/.github/actions/configure-environment/action.yml b/.github/actions/configure-environment/action.yml index 1eacc5b..5647994 100644 --- a/.github/actions/configure-environment/action.yml +++ b/.github/actions/configure-environment/action.yml @@ -1,16 +1,15 @@ name: Configure Environment -description: Configures the conda environment runs: using: composite steps: - - - name: Initial setup - shell: bash - run: | - # filter conda environment file - cat environment.yml | grep -v "#.*\<\local\>" > ci-environment.yml - - - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: yardl - environment-file: ci-environment.yml + - name: strip environment.yml + shell: bash + # filter conda environment file + run: | + cat environment.yml | grep -v "#.*\<\local\>" > temp-ci-environment.yml + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: yardl + environment-file: temp-ci-environment.yml + - shell: bash + run: rm temp-ci-environment.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79a3852..2f5fc0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,60 +1,57 @@ name: CI - on: push: branches: [main] + tags: ['**'] paths-ignore: - - '**/*.md' - pull_request: - branches: [main] - -defaults: - run: - # See https://github.com/marketplace/actions/setup-miniconda#important - shell: bash -el {0} - + - '**/*.md' + pull_request: {branches: [main]} +defaults: {run: {shell: 'bash -el {0}'}} # https://github.com/marketplace/actions/setup-miniconda#important +env: + YARDL_VERSION: 0.6.2 jobs: validate: strategy: matrix: cppVersion: [17] - + environment: pypi + permissions: {id-token: write} name: Validate Python and C++${{ matrix.cppVersion }} runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Configure environment - uses: ./.github/actions/configure-environment - - - name: Install yardl - run: | - YARDL_DIR=${{github.workspace}}/yardl - mkdir ${YARDL_DIR} - cd ${YARDL_DIR} - echo "${{github.workspace}}/yardl" >> $GITHUB_PATH - YARDL_VERSION=0.3.2 - wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - - - name: Build model - run: | - cd model - yardl generate - - - name: Python - run: | - cd python - python petsird_generator.py | python petsird_analysis.py - - - name: Cpp - run: | - cd cpp && mkdir -p build && cd build - cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX" - ninja - ./petsird_generator test.h5 - ./petsird_analysis test.h5 + - uses: actions/checkout@v3 + with: {submodules: recursive} + - name: Configure environment + uses: ./.github/actions/configure-environment + - name: Install yardl + run: | + 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" + - name: Build model + run: | + cd model + yardl generate + - name: Python + run: | + cd python + python petsird_generator.py | python petsird_analysis.py + - name: cpp + run: | + mkdir ccp/build + cd cpp/build + cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX" + ninja + ./petsird_generator test.h5 + ./petsird_analysis test.h5 + - uses: casperdcl/deploy-pypi@v2 + with: + build: -s python -o dist + upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} + - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + uses: casperdcl/deploy-pypi@v2 + with: + url: https://test.pypi.org/legacy/ + password: ${{ secrets.TEST_PYPI_TOKEN }} diff --git a/.github/workflows/test_pypi.yml b/.github/workflows/test_pypi.yml deleted file mode 100644 index 09cabe1..0000000 --- a/.github/workflows/test_pypi.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Publish to TestPyPI - -on: - workflow_run: - workflows: [CI] - types: - - completed -env: - # Increase this to manually reset the conda environment cache - YARDL_VERSION: 0.6.2 - -jobs: - publish: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' # Adjust Python version as needed - - - name: Install required packages - run: | - pip install setuptools wheel twine build - - - name: Install yardl - run: | - YARDL_DIR=${{github.workspace}}/yardl - mkdir ${YARDL_DIR} - cd ${YARDL_DIR} - echo "${{github.workspace}}/yardl" >> $GITHUB_PATH - wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" - - - name: Run yardl - run: | - cd model - yardl generate - - - name: Publish to TestPyPI - run: | - cd python - python -m build - twine upload --repository-url https://test.pypi.org/legacy/ dist/* -u __token__ -p ${{ secrets.TEST_PYPI_TOKEN }} \ No newline at end of file