From 4e15abf969016620a6ac3aeae0153cca9fc3cc9a Mon Sep 17 00:00:00 2001 From: GuiMacielPereira Date: Mon, 2 Dec 2024 15:16:05 +0000 Subject: [PATCH] Run mvesuvio before uploading package During the nightly deployment workflow, it's best to test the basic functunality of config and make sure that at least this command does not give an error. In the case of conda, this is best done in the conda recipe, by adding a test section that runs the command for config. (Also added command to run unit tests) --- .../actions/publish-pypi-package/action.yml | 19 ++++++++++++++++--- .github/workflows/deploy_conda_nightly.yml | 19 ++++++++++--------- conda/meta.yaml | 9 +++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/actions/publish-pypi-package/action.yml b/.github/actions/publish-pypi-package/action.yml index 43ce82af..9936365e 100644 --- a/.github/actions/publish-pypi-package/action.yml +++ b/.github/actions/publish-pypi-package/action.yml @@ -14,13 +14,26 @@ runs: shell: bash -l {0} run: | conda config --set always_yes yes --set changeps1 no - conda create -n build-env-pypi python=3.10.* - conda activate build-env-pypi - mamba install -c conda-forge python-build twine + conda create -n build-env-pypi -c conda-forge python=3.10.* python-build twine - name: Build package shell: bash -l {0} run: | conda activate build-env-pypi python -m build + conda deactivate + + - name: Test basic functunality of mvesuvio + shell: bash -l {0} + run: | + mamba create -n mvesuvio-test + conda activate mvesuvio-test + pip install dist/*.whl + mvesuvio config + conda deactivate + + - name: Upload to PyPI + shell: bash -l {0} + run: | + conda activate build-env-pypi twine upload -u __token__ -p ${{ inputs.token }} dist/* diff --git a/.github/workflows/deploy_conda_nightly.yml b/.github/workflows/deploy_conda_nightly.yml index 60bc15d0..63365aad 100644 --- a/.github/workflows/deploy_conda_nightly.yml +++ b/.github/workflows/deploy_conda_nightly.yml @@ -1,11 +1,11 @@ name: Deploy mvesuvio nightly -on: - workflow_run: - workflows: ["mvesuvio nightly build"] - branches: [main] - types: - - completed +on: push + # workflow_run: + # workflows: ["mvesuvio nightly build"] + # branches: [main] + # types: + # - completed jobs: build_conda_and_upload: @@ -24,8 +24,9 @@ jobs: - name: Check for changes since last build run: | echo "recentCommits=$(test -z $(git log --since="yesterday" -1 --format=%h) && echo false || echo true)" >> $GITHUB_ENV + - name: Setup Miniconda - if: ${{ env.recentCommits == 'true'}} + # if: ${{ env.recentCommits == 'true'}} uses: conda-incubator/setup-miniconda@v2.2.0 with: miniforge-version: latest @@ -35,14 +36,14 @@ jobs: auto-activate-base: false - name: Build mvesuvio nightly conda package - if: ${{ env.recentCommits == 'true'}} + # if: ${{ env.recentCommits == 'true'}} uses: ./.github/actions/publish-conda-package with: label: nightly token: ${{ secrets.ANACONDA_API_TOKEN }} - name: Build mvesuvio nightly PyPI package - if: ${{ env.recentCommits == 'true'}} + # if: ${{ env.recentCommits == 'true'}} uses: ./.github/actions/publish-pypi-package with: token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/conda/meta.yaml b/conda/meta.yaml index b0492cbe..680e6164 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -34,6 +34,15 @@ requirements: test: imports: - mvesuvio + requires: + - pytest + - mock + source_files: + - tests/unit/ + - tools/ + commands: + - pytest + - mvesuvio config about: home: https://github.com/mantidproject/vesuvio