diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2021-05-23 15:05:27 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2021-05-23 16:00:44 -0500 |
commit | ae91e1647a56233484a59a34ce1bed805e21b301 (patch) | |
tree | 335766115577216427aee0081e3b75940df4adea /.github | |
parent | 2a62398e025ce8beed0e0f9f332a1ba9185a5999 (diff) | |
download | requests-cache-ae91e1647a56233484a59a34ce1bed805e21b301.tar.gz |
Split CI config into separate build and deploy files
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/build.yml | 67 | ||||
-rw-r--r-- | .github/workflows/deploy.yml | 91 |
2 files changed, 107 insertions, 51 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe9edfa..52fb96b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,16 +13,12 @@ env: COMPLEXITY_ARGS: '--show-complexity --average --order SCORE' jobs: - # Run unit tests for each supported python version + # Run unit tests for each supported python version and latest requests version test: runs-on: ubuntu-18.04 strategy: matrix: - python-version: [3.6] - # python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.1] - # One-time test for all versions >= 2.5 - # requests-version: [2.6, 2.6, 2.7, 2.8, 2.9, 2.10.0, 2.11, 2.12, 2.13, 2.14, 2.16, 2.17, 2.18, 2.19, 2.20.1, 2.21, 2.22, 2.23, 2.24, latest] - requests-version: [2.16, 2.17, 2.18, 2.19, 2.20.1, 2.21, 2.22, 2.23, 2.24, latest] + python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.1] fail-fast: false services: nginx: @@ -31,6 +27,7 @@ jobs: - 80:80 steps: + # Set up python + poetry - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: @@ -55,40 +52,31 @@ jobs: uses: actions/cache@v2 with: path: .venv - key: venv-${{ matrix.python-version }}-${{ matrix.requests-version }}-${{ hashFiles('poetry.lock') }} + key: venv-${{ matrix.python-version }}-latest-${{ hashFiles('poetry.lock') }} - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' - run: | - poetry add requests@${{ matrix.requests-version }} - poetry install -v -E backends + run: poetry install -v -E backends # Latest python version: Run tests with coverage and send to coveralls - # - name: Run tests with code coverage report - # if: ${{ matrix.python-version == env.LATEST_PY_VERSION }} && ${{ matrix.requests-version == 'latest' }} - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # run: | - # source $VENV - # pytest tests/unit --numprocesses=auto ${{ env.COVERAGE_ARGS }} - # pytest tests/integration --cov-append ${{ env.COVERAGE_ARGS }} - # pip install coveralls - # coveralls --service=github + - name: Run tests with code coverage report + if: ${{ matrix.python-version == env.LATEST_PY_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + source $VENV + pytest tests/unit --numprocesses=auto ${{ env.COVERAGE_ARGS }} + pytest tests/integration --cov-append ${{ env.COVERAGE_ARGS }} + pip install coveralls + coveralls --service=github # All other python versions: just run tests - name: Run tests - # if: ${{ matrix.python-version != env.LATEST_PY_VERSION }} || ${{ matrix.requests-version != 'latest' }} + if: ${{ matrix.python-version != env.LATEST_PY_VERSION }} run: | source $VENV pytest --numprocesses=auto tests/unit pytest tests/integration - # Run longer stress tests if this is a release or merge to master - - name: Run stress tests - if: startsWith(github.ref, 'refs/tags/v') || endsWith(github.ref, '/master') - run: | - source $VENV - export STRESS_TEST_MULTIPLIER=5 - pytest tests/integration/ -k 'multithreaded' # Run code analysis checks analyze: @@ -122,26 +110,3 @@ jobs: flake8 . - name: Run cyclomatic complexity check run: poetry run radon cc ${{ env.COMPLEXITY_ARGS }} requests_cache - - # Deploy pre-release builds from 'pre-release' branch, and stable builds on tags only - release: - needs: [test, analyze] - if: startsWith(github.ref, 'refs/tags/v') || endsWith(github.ref, '/pre-release') - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ env.LATEST_PY_VERSION }} - - uses: snok/install-poetry@v1.1.6 - with: - version: 1.2.0a1 - virtualenvs-in-project: true - - - name: Set pre-release version number - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} - run: poetry version $(poetry version -s).dev${GITHUB_RUN_NUMBER} - - name: Build and publish to pypi - run: - poetry build - poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b6ff179 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,91 @@ +# Prior to package deployments, this will run additional stress tests, +# plus tests for all supported versions of the requests library. +name: Deploy + +on: + push: + branches: [pre-release] + tags: ['v*'] + workflow_dispatch: +env: + LATEST_PY_VERSION: 3.9 + +jobs: + # Run unit tests for oldest supported python version and all supported requests versions + test: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.6] + requests-version: [2.17, 2.18, 2.19, 2.20.1, 2.21, 2.22, 2.23, 2.24, latest] + fail-fast: false + services: + nginx: + image: kennethreitz/httpbin + ports: + - 80:80 + + steps: + # Set up python + poetry + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: snok/install-poetry@v1.1.6 + with: + version: 1.2.0a1 + virtualenvs-in-project: true + + # Start integration test databases + - uses: supercharge/mongodb-github-action@1.3.0 + with: + mongodb-version: 4.4 + - uses: supercharge/redis-github-action@1.2.0 + with: + redis-version: 6 + - uses: rrainn/dynamodb-action@v2.0.0 + + # Cache packages per python version, and reuse until lockfile changes + - name: Cache python packages + id: cache + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ matrix.python-version }}-${{ matrix.requests-version }}-${{ hashFiles('poetry.lock') }} + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + poetry add requests@${{ matrix.requests-version }} + poetry install -v -E backends + + # Run unit + integration tests, with additional stress tests + # Skip test for streaming responses; requires requests >= 2.19 (tested on latest version in build.yml) + - name: Run tests + run: | + source $VENV + pytest --numprocesses=auto tests/unit + pytest tests/integration -k 'not test_response_decode' + STRESS_TEST_MULTIPLIER=5 pytest tests/integration/ -k 'multithreaded' + + # Deploy pre-release builds from 'pre-release' branch, and stable builds on tags only + release: + needs: [test] + if: startsWith(github.ref, 'refs/tags/v') || endsWith(github.ref, '/pre-release') + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ env.LATEST_PY_VERSION }} + - uses: snok/install-poetry@v1.1.6 + with: + version: 1.2.0a1 + virtualenvs-in-project: true + + - name: Set pre-release version number + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: poetry version $(poetry version -s).dev${GITHUB_RUN_NUMBER} + - name: Build and publish to pypi + run: + poetry build + poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} |