diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ae0a07fd..4337b90d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -69,7 +69,7 @@ jobs: git fetch --tags - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.9' diff --git a/.github/workflows/install-project.yml b/.github/workflows/install-project.yml new file mode 100644 index 00000000..ef23fb5b --- /dev/null +++ b/.github/workflows/install-project.yml @@ -0,0 +1,54 @@ +name: Clone and Install Project +on: + workflow_call: + inputs: + python-version: + required: true + type: string + reference: + required: true + type: string + description: > + Reference ID to use for defining poetry cache (e.g. pull request id + or commit SHA) + +jobs: + install: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v3 + + # install & configure poetry + - name: Cache Poetry Installation + id: cached-poetry + uses: actions/cache@v3 + with: + path: ~/.local + key: ${{ runner.os }}-poetry-${{ inputs.reference }} + - name: Install Poetry + uses: snok/install-poetry@v1 + if: steps.cached-poetry.outputs.cache-hit != 'true' + with: + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Setup Python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + cache: 'poetry' + - name: Store Pip Cache + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} + restore-keys: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} + + # install dependencies + - name: Install dependencies + if: steps.setup-python.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-ansi --no-root + - name: Install library + run: poetry install --no-interaction --no-ansi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a463a491..baeba3a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,42 +18,11 @@ jobs: runs-on: ubuntu-latest steps: - - name: Clone repo - uses: actions/checkout@v3 - - # install & configure poetry - - name: Cache Poetry Installation - id: cached-poetry - uses: actions/cache@v3 - with: - path: ~/.local - key: ${{ runner.os }}-poetry-${{ github.event.pull_request.id || github.event.after }} - - name: Install Poetry - uses: snok/install-poetry@v1 - if: steps.cached-poetry.outputs.cache-hit != 'true' - with: - virtualenvs-create: true - virtualenvs-in-project: true - - - name: Setup Python - id: setup-python - uses: actions/setup-python@v4 + - name: Install + uses: ./.github/workflows/install-project.yml with: python-version: '3.11' - cache: 'poetry' - - name: Store Pip Cache - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - restore-keys: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - - # install dependencies - - name: Install dependencies - if: steps.setup-python.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-ansi --no-root - - name: Install library - run: poetry install --no-interaction --no-ansi + reference: ${{ github.event.pull_request.id || github.event.after }} # run python style checks - name: Poetry Lock Check @@ -74,41 +43,10 @@ jobs: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v3 - - # install & configure poetry - - name: Cache Poetry Installation - id: cached-poetry - uses: actions/cache@v3 - with: - path: ~/.local - key: ${{ runner.os }}-poetry-${{ github.event.pull_request.id || github.event.after }} - - name: Install Poetry - if: steps.cached-poetry.outputs.cache-hit != 'true' - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - - - name: Set up Python ${{ matrix.python-version }} - id: setup-python - uses: actions/setup-python@v4 + - uses: ./.github/workflows/install-project.yml with: python-version: ${{ matrix.python-version }} - cache: 'poetry' - - name: Store pip cache - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - restore-keys: | - ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - ${{ runner.os }}-pip- - - # install dependencies if cache does not exist - - name: Install dependencies - if: steps.setup-python.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root --no-ansi + reference: ${{ github.event.pull_request.id || github.event.after }} test: runs-on: ubuntu-latest @@ -119,50 +57,19 @@ jobs: split: ['1', '2', '3', '4', '5'] fail-fast: false steps: - - uses: actions/checkout@v3 - - # install & configure poetry - - name: Cache Poetry Installation - id: cached-poetry - uses: actions/cache@v3 - with: - path: ~/.local - key: ${{ runner.os }}-poetry-${{ github.event.pull_request.id || github.event.after }} - - name: Install Poetry - uses: snok/install-poetry@v1 - if: steps.cached-poetry.outputs.cache-hit != 'true' - with: - virtualenvs-create: true - virtualenvs-in-project: true - - - name: Set up Python ${{ matrix.python-version }} - id: setup-python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: poetry - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - restore-keys: | - ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }} - ${{ runner.os }}-pip- - - # install dependencies - - name: Install dependencies - if: steps.setup-python.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root --no-ansi - - name: Install library - run: poetry install --no-interaction --no-ansi - - - name: Test with pytest - env: - HYPOTHESIS_PROFILE: pr - run: >- - poetry run pytest -n auto --splits 5 --group ${{ matrix.split }} - --doctest-modules --ignore=docs - --ignore=snakebids/project_template --benchmark-disable + - name: install + uses: ./.github/workflows/install-project.yml + with: + python-version: ${{ matrix.python-version }} + reference: ${{ github.event.pull_request.id || github.event.after }} + + - name: Test with pytest + env: + HYPOTHESIS_PROFILE: pr + run: >- + poetry run pytest -n auto --splits 5 --group ${{ matrix.split }} + --doctest-modules --ignore=docs + --ignore=snakebids/project_template --benchmark-disable deployment_on_base: runs-on: ubuntu-latest