Improve CI workflow
* Build the package only once, and test on all platforms. * Deploy is now triggered manually via an Action, which is then responsible for tagging the repository after the package has been uploaded successfully. * Drop 'docs': we nowadays rely on readthedocs preview PR builds.
This commit is contained in:
		
							parent
							
								
									7a0a0e8b08
								
							
						
					
					
						commit
						7855a72d2c
					
				| 
						 | 
					@ -1,33 +1,38 @@
 | 
				
			||||||
name: deploy
 | 
					name: deploy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
on:
 | 
					on:
 | 
				
			||||||
  push:
 | 
					  workflow_dispatch:
 | 
				
			||||||
    tags:
 | 
					    inputs:
 | 
				
			||||||
      # These tags are protected, see:
 | 
					      version:
 | 
				
			||||||
      # https://github.com/pytest-dev/pytest/settings/tag_protection
 | 
					        description: 'Release version'
 | 
				
			||||||
      - "[0-9]+.[0-9]+.[0-9]+"
 | 
					        required: true
 | 
				
			||||||
      - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
 | 
					        default: '1.2.3'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set permissions at the job level.
 | 
					# Set permissions at the job level.
 | 
				
			||||||
permissions: {}
 | 
					permissions: {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  build:
 | 
					  package:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    env:
 | 
				
			||||||
 | 
					      SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
 | 
				
			||||||
    timeout-minutes: 10
 | 
					    timeout-minutes: 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - uses: actions/checkout@v3
 | 
					    - uses: actions/checkout@v3
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        fetch-depth: 0
 | 
					        fetch-depth: 0
 | 
				
			||||||
        persist-credentials: false
 | 
					        persist-credentials: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Build and Check Package
 | 
					    - name: Build and Check Package
 | 
				
			||||||
      uses: hynek/build-and-inspect-python-package@v1.5
 | 
					      uses: hynek/build-and-inspect-python-package@v1.5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  deploy:
 | 
					  deploy:
 | 
				
			||||||
    if: github.repository == 'pytest-dev/pytest'
 | 
					    if: github.repository == 'pytest-dev/pytest'
 | 
				
			||||||
    needs: [build]
 | 
					    needs: [package]
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    environment: deploy
 | 
				
			||||||
    timeout-minutes: 30
 | 
					    timeout-minutes: 30
 | 
				
			||||||
    permissions:
 | 
					    permissions:
 | 
				
			||||||
      id-token: write
 | 
					      id-token: write
 | 
				
			||||||
| 
						 | 
					@ -37,9 +42,17 @@ jobs:
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        name: Packages
 | 
					        name: Packages
 | 
				
			||||||
        path: dist
 | 
					        path: dist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Publish package to PyPI
 | 
					    - name: Publish package to PyPI
 | 
				
			||||||
      uses: pypa/gh-action-pypi-publish@v1.8.5
 | 
					      uses: pypa/gh-action-pypi-publish@v1.8.5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: Push tag
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        git config user.name "pytest bot"
 | 
				
			||||||
 | 
					        git config user.email "pytestbot@gmail.com"
 | 
				
			||||||
 | 
					        git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
 | 
				
			||||||
 | 
					        git push origin v${{ github.event.inputs.version }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  release-notes:
 | 
					  release-notes:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # todo: generate the content in the build  job
 | 
					    # todo: generate the content in the build  job
 | 
				
			||||||
| 
						 | 
					@ -55,11 +68,11 @@ jobs:
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        fetch-depth: 0
 | 
					        fetch-depth: 0
 | 
				
			||||||
        persist-credentials: false
 | 
					        persist-credentials: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Set up Python
 | 
					    - name: Set up Python
 | 
				
			||||||
      uses: actions/setup-python@v4
 | 
					      uses: actions/setup-python@v4
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        python-version: "3.7"
 | 
					        python-version: "3.10"
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Install tox
 | 
					    - name: Install tox
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,19 @@ concurrency:
 | 
				
			||||||
permissions: {}
 | 
					permissions: {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
 | 
					  package:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - uses: actions/checkout@v3
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        fetch-depth: 0
 | 
				
			||||||
 | 
					        persist-credentials: false
 | 
				
			||||||
 | 
					    - name: Build and Check Package
 | 
				
			||||||
 | 
					      uses: hynek/build-and-inspect-python-package@v1.5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  build:
 | 
					  build:
 | 
				
			||||||
 | 
					    needs: [package]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    runs-on: ${{ matrix.os }}
 | 
					    runs-on: ${{ matrix.os }}
 | 
				
			||||||
    timeout-minutes: 45
 | 
					    timeout-minutes: 45
 | 
				
			||||||
    permissions:
 | 
					    permissions:
 | 
				
			||||||
| 
						 | 
					@ -60,7 +72,6 @@ jobs:
 | 
				
			||||||
          "macos-py310",
 | 
					          "macos-py310",
 | 
				
			||||||
          "macos-py312",
 | 
					          "macos-py312",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          "docs",
 | 
					 | 
				
			||||||
          "doctesting",
 | 
					          "doctesting",
 | 
				
			||||||
          "plugins",
 | 
					          "plugins",
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
| 
						 | 
					@ -159,10 +170,6 @@ jobs:
 | 
				
			||||||
            os: ubuntu-latest
 | 
					            os: ubuntu-latest
 | 
				
			||||||
            tox_env: "plugins"
 | 
					            tox_env: "plugins"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          - name: "docs"
 | 
					 | 
				
			||||||
            python: "3.7"
 | 
					 | 
				
			||||||
            os: ubuntu-latest
 | 
					 | 
				
			||||||
            tox_env: "docs"
 | 
					 | 
				
			||||||
          - name: "doctesting"
 | 
					          - name: "doctesting"
 | 
				
			||||||
            python: "3.7"
 | 
					            python: "3.7"
 | 
				
			||||||
            os: ubuntu-latest
 | 
					            os: ubuntu-latest
 | 
				
			||||||
| 
						 | 
					@ -175,6 +182,12 @@ jobs:
 | 
				
			||||||
        fetch-depth: 0
 | 
					        fetch-depth: 0
 | 
				
			||||||
        persist-credentials: false
 | 
					        persist-credentials: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: Download Package
 | 
				
			||||||
 | 
					      uses: actions/download-artifact@v3
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        name: Packages
 | 
				
			||||||
 | 
					        path: dist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Set up Python ${{ matrix.python }}
 | 
					    - name: Set up Python ${{ matrix.python }}
 | 
				
			||||||
      uses: actions/setup-python@v4
 | 
					      uses: actions/setup-python@v4
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
| 
						 | 
					@ -188,11 +201,13 @@ jobs:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Test without coverage
 | 
					    - name: Test without coverage
 | 
				
			||||||
      if: "! matrix.use_coverage"
 | 
					      if: "! matrix.use_coverage"
 | 
				
			||||||
      run: "tox -e ${{ matrix.tox_env }}"
 | 
					      shell: bash
 | 
				
			||||||
 | 
					      run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Test with coverage
 | 
					    - name: Test with coverage
 | 
				
			||||||
      if: "matrix.use_coverage"
 | 
					      if: "matrix.use_coverage"
 | 
				
			||||||
      run: "tox -e ${{ matrix.tox_env }}-coverage"
 | 
					      shell: bash
 | 
				
			||||||
 | 
					      run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Generate coverage report
 | 
					    - name: Generate coverage report
 | 
				
			||||||
      if: "matrix.use_coverage"
 | 
					      if: "matrix.use_coverage"
 | 
				
			||||||
| 
						 | 
					@ -206,10 +221,3 @@ jobs:
 | 
				
			||||||
        fail_ci_if_error: true
 | 
					        fail_ci_if_error: true
 | 
				
			||||||
        files: ./coverage.xml
 | 
					        files: ./coverage.xml
 | 
				
			||||||
        verbose: true
 | 
					        verbose: true
 | 
				
			||||||
 | 
					 | 
				
			||||||
  check-package:
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
    - uses: actions/checkout@v3
 | 
					 | 
				
			||||||
    - name: Build and Check Package
 | 
					 | 
				
			||||||
      uses: hynek/build-and-inspect-python-package@v1.5
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,14 +133,11 @@ Releasing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Both automatic and manual processes described above follow the same steps from this point onward.
 | 
					Both automatic and manual processes described above follow the same steps from this point onward.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#. After all tests pass and the PR has been approved, tag the release commit
 | 
					#. After all tests pass and the PR has been approved, trigger the ``deploy`` job
 | 
				
			||||||
   in the ``release-MAJOR.MINOR.PATCH`` branch and push it. This will publish to PyPI::
 | 
					   in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     git fetch upstream
 | 
					   This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
 | 
				
			||||||
     git tag MAJOR.MINOR.PATCH upstream/release-MAJOR.MINOR.PATCH
 | 
					   and tag the repository.
 | 
				
			||||||
     git push upstream MAJOR.MINOR.PATCH
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
 | 
					#. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue