diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee12786..e80a46f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,15 +3,29 @@ on: push: branches: - master + - main + - poetry pull_request: branches: - master + - main + - poetry # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + inputs: + poetry: + type: boolean + description: "Use Poetry-based workflow." + required: false # Allow this workflow to be called from other repositories. workflow_call: + inputs: + poetry: + type: boolean + description: "Use Poetry-based workflow." + required: false jobs: run-tests: @@ -32,18 +46,40 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up Poetry - uses: abatilo/actions-poetry@v2 + if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }} + uses: abatilo/actions-poetry@v3 with: - poetry-version: "1.7.1" + poetry-version: "1.8.3" - - name: Install dependencies + - name: Install dependencies with Poetry + if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }} run: | poetry install --with test --all-extras poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git - - name: Run Pytest + - name: Run Pytest with Poetry + if: ${{ inputs.poetry || github.event_name == 'push' || github.event_name == 'pull_request' }} run: poetry run pytest -m "not webtest" --cov --cov-report=xml + - name: Install dependencies without Poetry + if: ${{ ! inputs.poetry && github.event_name != 'push' && github.event_name != 'pull_request' }} + run: | + python -m pip install --upgrade pip + pip install git+https://github.com/AstarVienna/ScopeSim_Data.git + # Install this clone of the project. This is relevant because for + # example ScopeSim has ScopeSim_Templates as a test-dependency + # and that package has ScopeSim as a dependency. So the PyPI version + # of ScopeSim would be installed without the "pip install ." line. + pip install . + # TODO: It should not be necessary to install the dev dependencies. + # Perhaps create a separate test for that? + pip install .[test,dev] + pip install pytest pytest-cov + + - name: Run Pytest without Poetry + if: ${{ ! inputs.poetry && github.event_name != 'push' && github.event_name != 'pull_request' }} + run: pytest -m "not webtest" --cov --cov-report=xml + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 env: diff --git a/.github/workflows/updated_tests.yml b/.github/workflows/updated_tests.yml index 8753786..83ae7e2 100644 --- a/.github/workflows/updated_tests.yml +++ b/.github/workflows/updated_tests.yml @@ -3,9 +3,13 @@ on: push: branches: - master + - main + - poetry pull_request: branches: - master + - main + - poetry # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -13,6 +17,8 @@ on: # Allow this workflow to be called from other repositories. workflow_call: +# This workflow need Poetry, so no flag is included. + jobs: run-tests: name: ${{ matrix.os }}, ${{ matrix.python-version }} @@ -27,14 +33,14 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Set up Poetry - uses: abatilo/actions-poetry@v2 + uses: abatilo/actions-poetry@v3 with: - poetry-version: "1.7.1" + poetry-version: "1.8.3" - name: Install dependencies run: | diff --git a/.github/workflows/webtests.yml b/.github/workflows/webtests.yml index 2438db9..5e09c5a 100644 --- a/.github/workflows/webtests.yml +++ b/.github/workflows/webtests.yml @@ -1,17 +1,20 @@ name: Tests on: - push: - branches: - - master - pull_request: - branches: - - master - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + inputs: + poetry: + type: boolean + description: "Use Poetry-based workflow." + required: false # Allow this workflow to be called from other repositories. workflow_call: + inputs: + poetry: + type: boolean + description: "Use Poetry-based workflow." + required: false jobs: run-tests: @@ -28,24 +31,46 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Set up Poetry - uses: abatilo/actions-poetry@v2 + if: inputs.poetry + uses: abatilo/actions-poetry@v3 with: - poetry-version: "1.7.1" + poetry-version: "1.8.3" - - name: Install dependencies + - name: Install dependencies with Poetry + if: inputs.poetry run: | poetry install --with test --all-extras poetry add git+https://github.com/AstarVienna/ScopeSim_Data.git - - name: Run Pytest + - name: Run Pytest with Poetry + if: inputs.poetry run: poetry run pytest -m "webtest" --cov --cov-report=xml + - name: Install dependencies without Poetry + if: ${{ ! inputs.poetry }} + run: | + python -m pip install --upgrade pip + pip install git+https://github.com/AstarVienna/ScopeSim_Data.git + # Install this clone of the project. This is relevant because for + # example ScopeSim has ScopeSim_Templates as a test-dependency + # and that package has ScopeSim as a dependency. So the PyPI version + # of ScopeSim would be installed without the "pip install ." line. + pip install . + # TODO: It should not be necessary to install the dev dependencies. + # Perhaps create a separate test for that? + pip install .[test,dev] + pip install pytest pytest-cov + + - name: Run Pytest without Poetry + if: ${{ ! inputs.poetry }} + run: pytest -m "webtest" --cov --cov-report=xml + - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }}