diff --git a/.github/actions/bootstrap-poetry/action.yml b/.github/actions/bootstrap-poetry/action.yml new file mode 100644 index 00000000000..e33e9af07b9 --- /dev/null +++ b/.github/actions/bootstrap-poetry/action.yml @@ -0,0 +1,34 @@ +name: Bootstrap Poetry +description: Configure the environment with the specified Python and Poetry version. + +inputs: + python-version: + description: Desired Python version + default: "3.12" + python-latest: + description: Use an uncached Python if a newer match is available + default: 'false' + poetry-spec: + description: pip-compatible installation specification to use for Poetry + default: 'poetry' + +runs: + using: composite + steps: + # Enable handling long path names (+260 char) on the Windows platform + # https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation + - id: git-config-longpaths + if: runner.os == 'Windows' + shell: pwsh + run: git config --system core.longpaths true + + - id: pipx-poetry + shell: bash + run: pipx install '${{ inputs.poetry-spec }}' + + - id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + check-latest: ${{ inputs.python-latest == 'true' }} + cache: poetry diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 5ab22316e6f..619dd1e99e3 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -33,43 +33,36 @@ jobs: with: repository: python-poetry/website - - name: Bootstrap poetry - run: pipx install poetry - - name: Checkout Poetry Source uses: actions/checkout@v4 with: path: poetry ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-node@v4 with: - python-version: "3.12" - cache: poetry + node-version: "18" - - name: Setup Node - uses: actions/setup-node@v4 + - uses: peaceiris/actions-hugo@v2 with: - node-version: "18" + hugo-version: '0.83.1' - - name: Build Assets - run: npm ci && npm run prod + - uses: ./.github/actions/bootstrap-poetry - - name: Fetch Documentation - run: | - poetry install --no-root --only main - poetry run python bin/website build --local ./poetry + - run: poetry install --no-root --only main - - name: Install Hugo - uses: peaceiris/actions-hugo@v2 - with: - hugo-version: '0.83.1' + - name: Build Website + run: | + set -eux -o pipefail - - name: Build - run: hugo -v --minify + # Rebuild the docs files from the PR checkout. + poetry run python bin/website build --local ./poetry + # Build website assets (CSS/JS). + npm ci && npm run prod + # Build the static website. + hugo -v --minify - - name: Deploy + - name: Deploy Website uses: amondnet/vercel-action@v25 id: vercel-action with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 07b1d0f58ab..6eed82e4a94 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -48,23 +48,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Bootstrap poetry - run: pipx install poetry + - uses: ./.github/actions/bootstrap-poetry - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: poetry - - - name: Configure poetry - run: | - poetry config virtualenvs.in-project true - poetry config virtualenvs.options.no-pip true - poetry config virtualenvs.options.no-setuptools true - - - name: Install dependencies - run: poetry install --only main,test + - run: poetry install --only main,test - name: Regenerate PyPI fixtures run: PYTHONPATH="$PWD" poetry run python tests/repositories/fixtures/pypi.org/generate.py @@ -92,38 +78,18 @@ jobs: - uses: actions/checkout@v4 if: needs.changes.outputs.pytest == 'true' - - name: Bootstrap poetry - if: needs.changes.outputs.pytest == 'true' - run: pipx install poetry - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: ./.github/actions/bootstrap-poetry if: needs.changes.outputs.pytest == 'true' with: python-version: ${{ matrix.python-version }} - cache: poetry - - - name: Enable long paths for git on Windows - if: needs.changes.outputs.pytest == 'true' && matrix.os == 'Windows' - # Enable handling long path names (+260 char) on the Windows platform - # https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation - run: git config --system core.longpaths true - - name: Configure poetry + - run: poetry install --with github-actions if: needs.changes.outputs.pytest == 'true' - run: | - poetry config virtualenvs.in-project true - poetry config virtualenvs.options.no-pip true - poetry config virtualenvs.options.no-setuptools true - name: Check lock file if: needs.changes.outputs.pytest == 'true' run: poetry check --lock - - name: Install dependencies - if: needs.changes.outputs.pytest == 'true' - run: poetry install --with github-actions - - name: Run mypy if: needs.changes.outputs.pytest == 'true' run: poetry run mypy