1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
# https://github.com/di/pip-api/blob/60691ed6bdc0c213253593de869bff1cf9195b81/.github/workflows/test.yml
# Copyright: 2018-2024 Dustin Ingram
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Test
on: [push, pull_request]
concurrency:
group: >-
${{
github.workflow
}}-${{
github.ref_type
}}-${{
github.event.pull_request.number || github.sha
}}
cancel-in-progress: true
env:
dists-artifact-name: python-package-distributions
sdist-artifact-name-wildcard: pip-api-*.tar.gz
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
- name: Install tox
run: python -m pip install tox
- name: Run linting
run: python -m tox -e lint
build-sdist:
name: 📦 Build the source distribution
runs-on: ubuntu-latest
steps:
- name: Grab the src from GH
uses: actions/checkout@v4
- name: Install `pypa/build` PEP 517 front-end
run: python -m pip install 'build ~= 0.10.0'
- name: 📦 Build an sdist
run: python -m build --sdist
- name: Verify that the artifact with expected name got created
run: >-
ls -1
dist/${{ env.sdist-artifact-name-wildcard }}
- name: Store the distribution package
uses: actions/upload-artifact@v3
with:
name: ${{ env.dists-artifact-name }}
# NOTE: Exact expected file names are specified here
# NOTE: as a safety measure — if anything weird ends
# NOTE: up being in this dir or not all dists will be
# NOTE: produced, this will fail the workflow.
path: |
dist/${{ env.sdist-artifact-name-wildcard }}
retention-days: 15
build-matrix:
name: Build the test matrix
needs: lint
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
- name: Install tox
run: python -m pip install tox
- id: set-matrix
run: >-
echo "matrix=$(python generate_matrix.py)" >> "${GITHUB_OUTPUT}"
test:
name: ${{ matrix.toxenv }}
needs:
- build-matrix
- build-sdist
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
steps:
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v1
with:
source-tarball-name: ${{ env.sdist-artifact-name-wildcard }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: python -m pip install tox
- name: Run tests
run: python -m tox -e ${{ matrix.toxenv }}
check:
if: always()
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
|