Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use early return pattern to avoid nested conditions #566

Merged
merged 2 commits into from
Dec 19, 2022
Merged

refactor: Use early return pattern to avoid nested conditions #566

merged 2 commits into from
Dec 19, 2022

Conversation

jongwooo
Copy link
Contributor

@jongwooo jongwooo commented Dec 12, 2022

Signed-off-by: jongwooo jongwooo.han@gmail.com
Issue #557

Description

Return early is the way of writing functions or methods so that the expected positive result is returned at the end of the function and the rest of the code terminates the execution (by returning or throwing an exception) when conditions are not met.

See actions/cache#1012, actions/setup-node#639

In utils.ts:

AS-IS

export function isCacheFeatureAvailable(): boolean {
  if (!cache.isFeatureAvailable()) {
    if (isGhes()) {
      throw new Error(
        'Caching is only supported on GHES version >= 3.5....'
      );
    } else {
      core.warning(
        'The runner was not able to...'
      );
    }

    return false;
  }

  return true;
}

TO-BE

export function isCacheFeatureAvailable(): boolean {
  if (cache.isFeatureAvailable()) {
    return true;
  }

  if (isGhes()) {
    throw new Error(
      'Caching is only supported on GHES version >= 3.5...'
    );
  }

  core.warning(
    'The runner was not able to...'
  );
  return false;
}

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Signed-off-by: jongwooo <jongwooo.han@gmail.com>
@jongwooo jongwooo requested a review from a team December 12, 2022 12:01
@jongwooo jongwooo changed the title refactor: Use early return pattern refactor: Use early return pattern to avoid nested conditions Dec 12, 2022
src/utils.ts Outdated Show resolved Hide resolved
Signed-off-by: jongwooo <jongwooo.han@gmail.com>
@MaksimZhukov MaksimZhukov merged commit 206e984 into actions:main Dec 19, 2022
@jongwooo jongwooo deleted the refactor/use-early-return-pattern branch December 19, 2022 13:02
estahn pushed a commit to estahn/k8s-image-swapper that referenced this pull request Jan 1, 2023
## [1.4.0](v1.3.3...v1.4.0) (2023-01-01)

### 👷 Build System

* **deps-dev:** Bump @semantic-release/changelog from 6.0.1 to 6.0.2 ([#404](#404)) ([ee56dbc](ee56dbc)), closes [#276](#276) [#276](#276) [#272](#272) [#275](#275) [#273](#273) [#274](#274) [#271](#271) [#270](#270) [#269](#269) [#268](#268) [#267](#267)

### 🎉 Features

* add custom tags to created ECR repositories ([#191](#191)) ([9849df2](9849df2))

### 📝 Documentation

* fix indentation ([b00c57e](b00c57e))

### ⬆️ Dependencies

* **deps:** Bump actions/cache from 3.0.11 to 3.2.1 ([#417](#417)) ([7e7eb8f](7e7eb8f)), closes [actions/cache#1039](actions/cache#1039) [actions/cache#1023](actions/cache#1023) [actions/cache#959](actions/cache#959) [actions/cache#960](actions/cache#960) [actions/cache#963](actions/cache#963) [actions/cache#961](actions/cache#961) [actions/cache#976](actions/cache#976) [actions/cache#971](actions/cache#971) [actions/cache#979](actions/cache#979) [actions/cache#986](actions/cache#986) [actions/cache#981](actions/cache#981) [actions/cache#997](actions/cache#997) [actions/cache#998](actions/cache#998) [actions/cache#1005](actions/cache#1005) [actions/cache#1007](actions/cache#1007) [actions/cache#1013](actions/cache#1013) [actions/cache#1004](actions/cache#1004) [actions/cache#1014](actions/cache#1014) [actions/cache#1008](actions/cache#1008) [actions/cache#1026](actions/cache#1026) [actions/cache#929](actions/cache#929) [actions/cache#1035](actions/cache#1035) [actions/cache#959](actions/cache#959) [actions/cache#979](actions/cache#979) [actions/cache#1013](actions/cache#1013) [actions/cache#1026](actions/cache#1026) [actions/cache#929](actions/cache#929) [actions/cache#1006](actions/cache#1006) [#1023](https://github.com/estahn/k8s-image-swapper/issues/1023) [#1039](https://github.com/estahn/k8s-image-swapper/issues/1039) [#1035](https://github.com/estahn/k8s-image-swapper/issues/1035) [#929](https://github.com/estahn/k8s-image-swapper/issues/929) [#1026](https://github.com/estahn/k8s-image-swapper/issues/1026) [#1008](https://github.com/estahn/k8s-image-swapper/issues/1008) [#1014](https://github.com/estahn/k8s-image-swapper/issues/1014) [#1004](https://github.com/estahn/k8s-image-swapper/issues/1004)
* **deps:** Bump actions/setup-python from 4.3.0 to 4.3.1 ([#406](#406)) ([16da762](16da762)), closes [actions/setup-python#559](actions/setup-python#559) [actions/setup-python#511](actions/setup-python#511) [actions/setup-python#558](actions/setup-python#558) [#559](#559) [#558](#558) [#549](#549) [#546](#546) [#545](#545) [#535](#535) [#510](#510) [#511](#511) [#520](#520)
* **deps:** Bump actions/setup-python from 4.3.1 to 4.4.0 ([#418](#418)) ([77872f8](77872f8)), closes [actions/setup-python#566](actions/setup-python#566) [#567](#567) [#569](#569) [#566](#566)
* **deps:** Bump github.com/aws/aws-sdk-go from 1.44.146 to 1.44.152 ([#403](#403)) ([9db51fd](9db51fd)), closes [#4652](https://github.com/estahn/k8s-image-swapper/issues/4652) [#4650](https://github.com/estahn/k8s-image-swapper/issues/4650) [#4648](https://github.com/estahn/k8s-image-swapper/issues/4648) [#4647](https://github.com/estahn/k8s-image-swapper/issues/4647) [#4646](https://github.com/estahn/k8s-image-swapper/issues/4646) [#4644](https://github.com/estahn/k8s-image-swapper/issues/4644) [#4639](https://github.com/estahn/k8s-image-swapper/issues/4639)
* **deps:** Bump github.com/aws/aws-sdk-go from 1.44.152 to 1.44.157 ([#411](#411)) ([2188432](2188432)), closes [#4658](https://github.com/estahn/k8s-image-swapper/issues/4658) [#4657](https://github.com/estahn/k8s-image-swapper/issues/4657) [#4656](https://github.com/estahn/k8s-image-swapper/issues/4656) [#4654](https://github.com/estahn/k8s-image-swapper/issues/4654) [#4653](https://github.com/estahn/k8s-image-swapper/issues/4653)
* **deps:** Bump github.com/aws/aws-sdk-go from 1.44.157 to 1.44.162 ([#415](#415)) ([f70fcd9](f70fcd9)), closes [#4666](https://github.com/estahn/k8s-image-swapper/issues/4666) [#4665](https://github.com/estahn/k8s-image-swapper/issues/4665) [#4663](https://github.com/estahn/k8s-image-swapper/issues/4663) [#4661](https://github.com/estahn/k8s-image-swapper/issues/4661) [#4660](https://github.com/estahn/k8s-image-swapper/issues/4660)
* **deps:** Bump github.com/aws/aws-sdk-go from 1.44.162 to 1.44.167 ([#419](#419)) ([f8b91fe](f8b91fe)), closes [#4671](https://github.com/estahn/k8s-image-swapper/issues/4671) [#4670](https://github.com/estahn/k8s-image-swapper/issues/4670) [#4669](https://github.com/estahn/k8s-image-swapper/issues/4669) [#4668](https://github.com/estahn/k8s-image-swapper/issues/4668) [#4667](https://github.com/estahn/k8s-image-swapper/issues/4667)
* **deps:** Bump github.com/gruntwork-io/terratest from 0.41.3 to 0.41.4 ([#402](#402)) ([16dde07](16dde07)), closes [#1208](https://github.com/estahn/k8s-image-swapper/issues/1208)
* **deps:** Bump github.com/gruntwork-io/terratest from 0.41.4 to 0.41.6 ([#409](#409)) ([9fc87df](9fc87df)), closes [#1214](https://github.com/estahn/k8s-image-swapper/issues/1214) [#1198](https://github.com/estahn/k8s-image-swapper/issues/1198)
* **deps:** Bump github.com/gruntwork-io/terratest from 0.41.6 to 0.41.7 ([#420](#420)) ([9ab97f2](9ab97f2)), closes [gruntwork-io/terratest#1217](gruntwork-io/terratest#1217) [#1217](https://github.com/estahn/k8s-image-swapper/issues/1217)
* **deps:** Bump goreleaser/goreleaser-action from 3.1.0 to 4.1.0 ([#414](#414)) ([e963ba1](e963ba1)), closes [goreleaser/goreleaser-action#382](goreleaser/goreleaser-action#382) [goreleaser/goreleaser-action#366](goreleaser/goreleaser-action#366) [goreleaser/goreleaser-action#379](goreleaser/goreleaser-action#379) [goreleaser/goreleaser-action#383](goreleaser/goreleaser-action#383) [goreleaser/goreleaser-action#366](goreleaser/goreleaser-action#366) [goreleaser/goreleaser-action#379](goreleaser/goreleaser-action#379) [goreleaser/goreleaser-action#370](goreleaser/goreleaser-action#370) [#374](#374) [#372](#372) [#373](#373) [#383](#383) [#366](#366) [#382](#382) [#370](#370)
* **deps:** Bump k8s.io/api from 0.25.4 to 0.26.0 ([#407](#407)) ([d13bf5e](d13bf5e)), closes [#111023](https://github.com/estahn/k8s-image-swapper/issues/111023) [#113375](https://github.com/estahn/k8s-image-swapper/issues/113375) [#113186](https://github.com/estahn/k8s-image-swapper/issues/113186)
* **deps:** Bump k8s.io/client-go from 0.25.4 to 0.26.0 ([#410](#410)) ([bcc56b5](bcc56b5)), closes [#113797](https://github.com/estahn/k8s-image-swapper/issues/113797) [#111023](https://github.com/estahn/k8s-image-swapper/issues/111023) [#113826](https://github.com/estahn/k8s-image-swapper/issues/113826) [#113375](https://github.com/estahn/k8s-image-swapper/issues/113375)
welpaolo referenced this pull request in canonical/spark-k8s-toolkit-py Aug 14, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/setup-python](https://togithub.com/actions/setup-python) |
action | major | `v2.2.2` -> `v4.7.0` |
|
[canonical/data-platform-workflows](https://togithub.com/canonical/data-platform-workflows)
| action | major | `v2` -> `v4` |

---

### Release Notes

<details>
<summary>actions/setup-python (actions/setup-python)</summary>

###
[`v4.7.0`](https://togithub.com/actions/setup-python/releases/tag/v4.7.0)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.6.1...v4.7.0)

In scope of this release, the support for reading python version from
pyproject.toml was added
([https://github.com/actions/setup-python/pull/669](https://togithub.com/actions/setup-python/pull/669)).

```yaml
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version-file: pyproject.toml
```

##### Besides, it includes such changes as:

- Bump tough-cookie and
[@&#8203;azure/ms-rest-js](https://togithub.com/azure/ms-rest-js) by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/actions/setup-python/pull/697](https://togithub.com/actions/setup-python/pull/697)
- Bump semver from 7.3.8 to 7.5.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/actions/setup-python/pull/692](https://togithub.com/actions/setup-python/pull/692)
- Fix typos found by codespell by
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
in
[https://github.com/actions/setup-python/pull/650](https://togithub.com/actions/setup-python/pull/650)

#### New Contributors

- [@&#8203;dariocurr](https://togithub.com/dariocurr) made their first
contribution in
[https://github.com/actions/setup-python/pull/669](https://togithub.com/actions/setup-python/pull/669)
-
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
made their first contribution in
[https://github.com/actions/setup-python/pull/650](https://togithub.com/actions/setup-python/pull/650)

**Full Changelog**:
actions/setup-python@v4...v4.7.0

###
[`v4.6.1`](https://togithub.com/actions/setup-python/releases/tag/v4.6.1)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.6.0...v4.6.1)

#### What's Changed

- Fix `allow-prereleases` sample configuration by
[@&#8203;mayeut](https://togithub.com/mayeut) in
[https://github.com/actions/setup-python/pull/615](https://togithub.com/actions/setup-python/pull/615)
- Fix a incorrect link advanced-usage.md by
[@&#8203;siyuan0322](https://togithub.com/siyuan0322) in
[https://github.com/actions/setup-python/pull/657](https://togithub.com/actions/setup-python/pull/657)
- Remove implicit dependency by
[@&#8203;nikolai-laevskii](https://togithub.com/nikolai-laevskii) in
[https://github.com/actions/setup-python/pull/668](https://togithub.com/actions/setup-python/pull/668)
- Automatic update of configuration files from 05/23/2023 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/actions/setup-python/pull/671](https://togithub.com/actions/setup-python/pull/671)
- Add warning for python 2.7 on release/v4 by
[@&#8203;dmitry-shibanov](https://togithub.com/dmitry-shibanov) in
[https://github.com/actions/setup-python/pull/673](https://togithub.com/actions/setup-python/pull/673)

#### New Contributors

- [@&#8203;siyuan0322](https://togithub.com/siyuan0322) made their first
contribution in
[https://github.com/actions/setup-python/pull/657](https://togithub.com/actions/setup-python/pull/657)
- [@&#8203;nikolai-laevskii](https://togithub.com/nikolai-laevskii) made
their first contribution in
[https://github.com/actions/setup-python/pull/668](https://togithub.com/actions/setup-python/pull/668)

**Full Changelog**:
actions/setup-python@v4...v4.6.1

###
[`v4.6.0`](https://togithub.com/actions/setup-python/releases/tag/v4.6.0):
Add allow-prereleases input

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.5.0...v4.6.0)

In scope of this release we added a new input (`allow-prereleases`) to
allow [falling back to pre-release versions of Python when a matching GA
version of Python is not
available](https://togithub.com/actions/setup-python/pull/414)

```yaml
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-python@v4
    with:
      python-version: 3.12
      allow-prereleases: true
```

Besides, we added such changes as:

- Fix bug to trim new line for PyPy version:
[https://github.com/actions/setup-python/pull/610](https://togithub.com/actions/setup-python/pull/610)
- Added pip dependency file to generate hash from it:
[https://github.com/actions/setup-python/pull/604](https://togithub.com/actions/setup-python/pull/604)
- Improved error handling for saving and restoring cache:
[https://github.com/actions/setup-python/pull/618](https://togithub.com/actions/setup-python/pull/618)
- Add warning if cache paths are empty:
[https://github.com/actions/setup-python/pull/642](https://togithub.com/actions/setup-python/pull/642)

###
[`v4.5.0`](https://togithub.com/actions/setup-python/releases/tag/v4.5.0):
Fix cache issue for Poetry projects located in subfolders

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.4.0...v4.5.0)

In scope of this release we fixed cache issue for Poetry projects
located in subfolders
([https://github.com/actions/setup-python/issues/446](https://togithub.com/actions/setup-python/issues/446)).
Besides that we updated json5 version from 2.2.0 to 2.2.3
([https://github.com/actions/setup-python/pull/579](https://togithub.com/actions/setup-python/pull/579)).

###
[`v4.4.0`](https://togithub.com/actions/setup-python/releases/tag/v4.4.0):
Add support to install multiple python versions

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.3.1...v4.4.0)

In scope of this release we added support to [install multiple python
versions](https://togithub.com/actions/setup-python/pull/567). For this
you can try to use this snippet:

```yaml
    - uses: actions/setup-python@v4
      with:
        python-version: |
            3.8
            3.9
            3.10
```

Besides, we changed logic with throwing the error for GHES if cache is
unavailable to warn
([https://github.com/actions/setup-python/pull/566](https://togithub.com/actions/setup-python/pull/566)).

###
[`v4.3.1`](https://togithub.com/actions/setup-python/releases/tag/v4.3.1):
Improve error handling and messages

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.3.0...v4.3.1)

In scope of this release we added improved error message to put
operating system and its version in the logs
([https://github.com/actions/setup-python/pull/559](https://togithub.com/actions/setup-python/pull/559)).
Besides, the release

- fixes issue about [specifying architecture for pypy-nightly on
Windows](https://togithub.com/actions/setup-python/issues/518) with
related [pull
request](https://togithub.com/actions/setup-python/pull/520).
- improves error handling for Http Errors
([https://github.com/actions/setup-python/pull/511](https://togithub.com/actions/setup-python/pull/511)).
- updates minimatch
([https://github.com/actions/setup-python/pull/558](https://togithub.com/actions/setup-python/pull/558)).

###
[`v4.3.0`](https://togithub.com/actions/setup-python/releases/tag/v4.3.0)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.2.0...v4.3.0)

- Update [@&#8203;actions/core](https://togithub.com/actions/core) to
1.10.0 version
[#&#8203;517](https://togithub.com/actions/setup-python/issues/517)
- Update [@&#8203;actions/cache](https://togithub.com/actions/cache) to
3.0.4 version
[#&#8203;499](https://togithub.com/actions/setup-python/issues/499)
- Only use github.token on github.com
[#&#8203;443](https://togithub.com/actions/setup-python/issues/443)
- Improvement of documentation
[#&#8203;477](https://togithub.com/actions/setup-python/issues/477)
[#&#8203;479](https://togithub.com/actions/setup-python/issues/479)
[#&#8203;491](https://togithub.com/actions/setup-python/issues/491)
[#&#8203;492](https://togithub.com/actions/setup-python/issues/492)

###
[`v4.2.0`](https://togithub.com/actions/setup-python/releases/tag/v4.2.0):
Add check-latest input and bug fixes

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.1.0...v4.2.0)

In scope of this release we add
the [check-latest](https://togithub.com/actions/setup-python/pull/406) input.
If check-latest is set to true, the action first checks if the cached
version is the latest one. If the locally cached version is not the most
up-to-date, the version will then be downloaded
from [python-versions](https://togithub.com/actions/python-versions) repository.
By default check-latest is set to false. For PyPy it will to try to
reach https://downloads.python.org/pypy/versions.json

##### Example of usage:

```yaml
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-python@v4
    with:
      python-version: '3.9'
      check-latest: true
  - run: python --version
```

Besides, it includes such changes as

- Resolved logs for python-version and file inputs:
[https://github.com/actions/setup-python/pull/465](https://togithub.com/actions/setup-python/pull/465)
- Added linux os release info to primary key:
[https://github.com/actions/setup-python/pull/467](https://togithub.com/actions/setup-python/pull/467)
- Added fix to change Python versions for poetry:
[https://github.com/actions/setup-python/pull/445](https://togithub.com/actions/setup-python/pull/445)
- Fix Tool Path handling for self-hosted runners:
[https://github.com/actions/setup-python/pull/466](https://togithub.com/actions/setup-python/pull/466)

###
[`v4.1.0`](https://togithub.com/actions/setup-python/releases/tag/v4.1.0)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v4.0.0...v4.1.0)

In scope of this pull request we updated `actions/cache` package as the
new version contains fixes for [caching error
handling](https://togithub.com/actions/setup-python/pull/448). Moreover,
we added a new input
[update-environment](https://togithub.com/actions/setup-python/pull/411).
This option allows to specify if the action shall update environment
variables (default) or not.

##### Update-environment input

```yaml
    - name: setup-python 3.9
      uses: actions/setup-python@v4
      with:
        python-version: 3.9
        update-environment: false
```

**Besides, we added such changes as:**

- Allow python-version-file to be a relative path:
[https://github.com/actions/setup-python/pull/431](https://togithub.com/actions/setup-python/pull/431)
- Added new environment variables for `Cmake`:
[https://github.com/actions/setup-python/pull/440](https://togithub.com/actions/setup-python/pull/440)
- Updated error message for resolveVersion:
[https://github.com/actions/setup-python/pull/450](https://togithub.com/actions/setup-python/pull/450)
- Assign default value of `AGENT_TOOLSDIRECTORY` if not set:
[https://github.com/actions/setup-python/pull/394](https://togithub.com/actions/setup-python/pull/394)

###
[`v4.0.0`](https://togithub.com/actions/setup-python/releases/tag/v4.0.0)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.1.4...v4.0.0)

##### What's Changed

- Support for `python-version-file` input:
[#&#8203;336](https://togithub.com/actions/setup-python/issues/336)

Example of usage:

```yaml
- uses: actions/setup-python@v4
  with:
    python-version-file: '.python-version' # Read python version from a file
- run: python my_script.py
```

There is no default python version for this `setup-python` major
version, the action requires to specify either `python-version` input or
`python-version-file` input. If the `python-version` input is not
specified the action will try to read required version from file from
`python-version-file` input.

- Use pypyX.Y for PyPy `python-version` input:
[#&#8203;349](https://togithub.com/actions/setup-python/issues/349)

Example of usage:

```yaml
- uses: actions/setup-python@v4
  with:
    python-version: 'pypy3.9' # pypy-X.Y kept for backward compatibility
- run: python my_script.py
```

- `RUNNER_TOOL_CACHE` environment variable is equal
`AGENT_TOOLSDIRECTORY`:
[#&#8203;338](https://togithub.com/actions/setup-python/issues/338)

- Bugfix: create missing `pypyX.Y` symlinks:
[#&#8203;347](https://togithub.com/actions/setup-python/issues/347)

- `PKG_CONFIG_PATH` environment variable:
[#&#8203;400](https://togithub.com/actions/setup-python/issues/400)

- Added `python-path` output:
[#&#8203;405](https://togithub.com/actions/setup-python/issues/405)
    `python-path` output contains Python executable path.

- Updated `zeit/ncc` to `vercel/ncc` package:
[#&#8203;393](https://togithub.com/actions/setup-python/issues/393)

- Bugfix: fixed output for prerelease version of poetry:
[#&#8203;409](https://togithub.com/actions/setup-python/issues/409)

- Made `pythonLocation` environment variable consistent for Python and
PyPy:
[#&#8203;418](https://togithub.com/actions/setup-python/issues/418)

- Bugfix for `3.x-dev` syntax:
[#&#8203;417](https://togithub.com/actions/setup-python/issues/417)

- Other improvements:
[#&#8203;318](https://togithub.com/actions/setup-python/issues/318)
[#&#8203;396](https://togithub.com/actions/setup-python/issues/396)
[#&#8203;384](https://togithub.com/actions/setup-python/issues/384)
[#&#8203;387](https://togithub.com/actions/setup-python/issues/387)
[#&#8203;388](https://togithub.com/actions/setup-python/issues/388)

###
[`v3.1.4`](https://togithub.com/actions/setup-python/releases/tag/v3.1.4)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.1.3...v3.1.4)

#### What's Changed

In the scope of this patch release, the warning for deprecating Python
2.x was added in
[https://github.com/actions/setup-python/pull/674](https://togithub.com/actions/setup-python/pull/674)
by [@&#8203;dmitry-shibanov](https://togithub.com/dmitry-shibanov)

For more information, check out
[https://github.com/actions/setup-python/issues/672](https://togithub.com/actions/setup-python/issues/672)

**Full Changelog**:
actions/setup-python@v3...v3.1.4

###
[`v3.1.3`](https://togithub.com/actions/setup-python/releases/tag/v3.1.3):
Update actions/core to 1.10.0 for v3

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.1.2...v3.1.3)

In scope of this release we update actions/core to 1.10.0 for v3 major
tag:
[https://github.com/actions/setup-python/pull/624](https://togithub.com/actions/setup-python/pull/624)

###
[`v3.1.2`](https://togithub.com/actions/setup-python/releases/tag/v3.1.2):
Update actions/cache version to 2.0.2

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.1.1...v3.1.2)

In scope of this release we updated `actions/cache` package as the new
version contains fixes related to GHES 3.5
([https://github.com/actions/setup-python/pull/382](https://togithub.com/actions/setup-python/pull/382))

###
[`v3.1.1`](https://togithub.com/actions/setup-python/releases/tag/v3.1.1):
Add &quot;cache-hit&quot; output and fix &quot;python-version&quot;
output for PyPy

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.1.0...v3.1.1)

This release introduces new output cache-hit
([https://github.com/actions/setup-python/pull/373](https://togithub.com/actions/setup-python/pull/373))
and fix python-version output for PyPy
([https://github.com/actions/setup-python/pull/365](https://togithub.com/actions/setup-python/pull/365))

The cache-hit output contains boolean value indicating that an exact
match was found for the key. It shows that the action uses already
existing cache or not. The output is available only if cache is enabled.

The python-version contains version of Python or PyPy.

###
[`v3.1.0`](https://togithub.com/actions/setup-python/releases/tag/v3.1.0):
Support caching poetry dependencies and caching on GHES 3.5

[Compare
Source](https://togithub.com/actions/setup-python/compare/v3.0.0...v3.1.0)

- In the scope of this release, we added [support for caching from GHES
3.5](https://togithub.com/actions/setup-python/issues/362) and fixed the
download issue for files > 2GB during restore.
-   Caching poetry dependencies

```yaml
steps:
- uses: actions/checkout@v3
- name: Install poetry
  run: pipx install poetry
- uses: actions/setup-python@v3
  with:
    python-version: '3.9'
    cache: 'poetry'
- run: poetry install
- run: poetry run pytest
```

###
[`v3.0.0`](https://togithub.com/actions/setup-python/releases/tag/v3.0.0)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.3.4...v3.0.0)

#### What's Changed

- Update default runtime to node16
([https://github.com/actions/setup-python/pull/340](https://togithub.com/actions/setup-python/pull/340))
- Update `package-lock.json` file version to 2, `@types/node` to
16.11.25 and `typescript` to 4.2.3
([https://github.com/actions/setup-python/pull/341](https://togithub.com/actions/setup-python/pull/341))
- Remove legacy `pypy2` and `pypy3` keywords
([https://github.com/actions/setup-python/pull/342](https://togithub.com/actions/setup-python/pull/342))

##### Breaking Changes

With the update to Node 16, all scripts will now be run with Node 16
rather than Node 12.

This new major release removes support of legacy `pypy2` and `pypy3`
keywords. Please use more specific and flexible syntax to specify a PyPy
version:

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
        - 'pypy-2.7' # the latest available version of PyPy that supports Python 2.7
        - 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8
        - 'pypy-3.8-v7.3.8' # Python 3.8 and PyPy 7.3.8
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
```

See more usage examples in the
[documentation](https://togithub.com/actions/setup-python#specifying-a-pypy-version)

###
[`v2.3.4`](https://togithub.com/actions/setup-python/releases/tag/v2.3.4)

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.3.3...v2.3.4)

#### What's Changed

In the scope of this patch release, the warning for deprecating Python
2.x was added in
[https://github.com/actions/setup-python/pull/675](https://togithub.com/actions/setup-python/pull/675)
by [@&#8203;dmitry-shibanov](https://togithub.com/dmitry-shibanov)

For more information, check out
[https://github.com/actions/setup-python/issues/672](https://togithub.com/actions/setup-python/issues/672)

**Full Changelog**:
actions/setup-python@v2...v2.3.4

###
[`v2.3.3`](https://togithub.com/actions/setup-python/releases/tag/v2.3.3):
Update actions/core to 1.10.0 for v2

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.3.2...v2.3.3)

In scope of this release we update actions/core to 1.10.0 for v2 major
tag:
[https://github.com/actions/setup-python/pull/533](https://togithub.com/actions/setup-python/pull/533).

###
[`v2.3.2`](https://togithub.com/actions/setup-python/releases/tag/v2.3.2):
Update primary and restore keys for pip

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.3.1...v2.3.2)

In scope of this release we [include a version of python in restore and
primary cache keys for
pip](https://togithub.com/actions/setup-python/pull/303). Besides, we
add temporary fix for Windows caching
[issue](https://togithub.com/actions/setup-python/pull/332), that the
`pip cache dir` command returns non zero exit code or writes to stderr.
Moreover we updated [node-fetch
dependency](https://togithub.com/actions/setup-python/pull/327).

###
[`v2.3.1`](https://togithub.com/actions/setup-python/releases/tag/v2.3.1):
Update actions/cache version to 1.0.8

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.3.0...v2.3.1)

We have
updated [actions/cache](https://togithub.com/actions/toolkit/blob/main/packages/cache/RELEASES.md#108) dependency
version to 1.0.8 to support 10GB cache upload

###
[`v2.3.0`](https://togithub.com/actions/setup-python/releases/tag/v2.3.0):
Support caching dependencies

[Compare
Source](https://togithub.com/actions/setup-python/compare/v2.2.2...v2.3.0)

This release introduces dependency caching support
([https://github.com/actions/setup-python/pull/266](https://togithub.com/actions/setup-python/pull/266))

#### Caching dependencies.

The action has a built-in functionality for caching and restoring
pip/pipenv dependencies. The `cache` input is optional, and caching is
turned off by default.

Besides, this release introduces dependency caching support for mono
repos and repositories with complex structure.

By default, the action searches for the dependency file
(requirements.txt for pip or Pipfile.lock for pipenv) in the whole
repository. Use the `cache-dependency-path` input for cases when you
want to override current behaviour and use different file for hash
generation (for example requirements-dev.txt). This input supports
wildcards or a list of file names for caching multiple dependencies.

##### Caching pip dependencies:

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: '3.9'
        cache: 'pip'
    - run: pip install -r requirements.txt
    - run: pip test

##### Caching pipenv dependencies:

    steps:
    - uses: actions/checkout@v2
    - name: Install pipenv
      run: pipx install pipenv
    - uses: actions/setup-python@v2
      with:
        python-version: '3.9'
        cache: 'pipenv'
    - run: pipenv install
    - run: pipenv test

##### Change dependency file:

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: '3.9'
        cache: 'pip'
        cache-dependency-path: '**/requirements-dev.txt'
    - run: pip install -r subdirectory/requirements-dev.txt
    - run: pip test

</details>

<details>
<summary>canonical/data-platform-workflows
(canonical/data-platform-workflows)</summary>

###
[`v4`](https://togithub.com/canonical/data-platform-workflows/compare/v3...v4)

[Compare
Source](https://togithub.com/canonical/data-platform-workflows/compare/v3...v4)

###
[`v3`](https://togithub.com/canonical/data-platform-workflows/compare/v2...v3)

[Compare
Source](https://togithub.com/canonical/data-platform-workflows/compare/v2...v3)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 1am and before 2am on saturday"
in timezone Etc/UTC, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/canonical/spark-k8s-toolkit-py).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi40MC4zIiwidXBkYXRlZEluVmVyIjoiMzYuNDAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants