diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16aef79..74f97e9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,6 +24,11 @@ on: description: "Use Poetry-based workflow." required: false default: true + trigger: + type: string + description: "Fake input parameter to tell if triggered from outside. Do not set manually." + required: false + default: "external" jobs: run-tests: @@ -38,29 +43,35 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Decide if poetry + id: decide + env: + USE_POETRY: "${{ (((github.event_name == 'pull_request') || (github.event_name == 'push')) && (inputs.trigger != 'external')) || ((inputs.poetry == true) && ((github.event_name == 'workflow_dispatch') || (inputs.trigger == 'external'))) }}" + run: echo "USE_POETRY=$USE_POETRY" >> "$GITHUB_OUTPUT" + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Set up Poetry - if: ${{ inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} uses: abatilo/actions-poetry@v3 with: poetry-version: "2.1.3" - name: Install dependencies with Poetry - if: ${{ inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} run: | poetry install --with test --all-extras poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git - name: Run Pytest with Poetry - if: ${{ inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} run: poetry run pytest -m "not webtest" --cov --cov-report=xml - name: Install dependencies without Poetry - if: ${{ ! inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'false' }} run: | python -m pip install --upgrade pip pip install git+https://github.com/AstarVienna/ScopeSim_Data.git @@ -75,7 +86,7 @@ jobs: pip install pytest pytest-cov - name: Run Pytest without Poetry - if: ${{ ! inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'false' }} run: pytest -m "not webtest" --cov --cov-report=xml - name: Upload coverage reports to Codecov diff --git a/.github/workflows/updated_tests.yml b/.github/workflows/updated_tests.yml index 051749e..c3366de 100644 --- a/.github/workflows/updated_tests.yml +++ b/.github/workflows/updated_tests.yml @@ -1,4 +1,4 @@ -name: Tests +name: Updated Tests on: push: branches: @@ -13,7 +13,7 @@ on: # Allow this workflow to be called from other repositories. workflow_call: -# This workflow need Poetry, so no flag is included. +# This workflow needs Poetry, so no flag is included. jobs: run-tests: diff --git a/.github/workflows/webtests.yml b/.github/workflows/webtests.yml index e4eb838..09bb717 100644 --- a/.github/workflows/webtests.yml +++ b/.github/workflows/webtests.yml @@ -1,4 +1,4 @@ -name: Tests +name: Webtests on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -15,6 +15,11 @@ on: type: boolean description: "Use Poetry-based workflow." required: false + trigger: + type: string + description: "Fake input parameter to tell if triggered from outside. Do not set manually." + required: false + default: "external" jobs: run-tests: @@ -30,29 +35,35 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Decide if poetry + id: decide + env: + USE_POETRY: "${{ (((github.event_name == 'pull_request') || (github.event_name == 'push')) && (inputs.trigger != 'external')) || ((inputs.poetry == true) && ((github.event_name == 'workflow_dispatch') || (inputs.trigger == 'external'))) }}" + run: echo "USE_POETRY=$USE_POETRY" >> "$GITHUB_OUTPUT" + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Set up Poetry - if: inputs.poetry + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} uses: abatilo/actions-poetry@v3 with: poetry-version: "2.1.3" - name: Install dependencies with Poetry - if: inputs.poetry + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} run: | poetry install --with test --all-extras poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git - name: Run Pytest with Poetry - if: inputs.poetry + if: ${{ steps.decide.outputs.USE_POETRY == 'true' }} run: poetry run pytest -m "webtest" --cov --cov-report=xml - name: Install dependencies without Poetry - if: ${{ ! inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'false' }} run: | python -m pip install --upgrade pip pip install git+https://github.com/AstarVienna/ScopeSim_Data.git @@ -67,7 +78,7 @@ jobs: pip install pytest pytest-cov - name: Run Pytest without Poetry - if: ${{ ! inputs.poetry }} + if: ${{ steps.decide.outputs.USE_POETRY == 'false' }} run: pytest -m "webtest" --cov --cov-report=xml - name: Upload coverage reports to Codecov