Skip to content

Commit

Permalink
feat(actions): add actions/setup-python@v5
Browse files Browse the repository at this point in the history
  • Loading branch information
krzema12 committed Dec 7, 2023
1 parent 1fedb2c commit 9f3d1ff
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Integration tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
name: 'Run alpine'
uses: 'docker://alpine:latest'
- id: 'step-8'
uses: 'actions/setup-python@v4'
uses: 'actions/setup-python@v5'
- id: 'step-9'
name: 'Some step consuming other step''s output'
uses: 'actions/checkout@v4'
Expand Down
Empty file.
1 change: 1 addition & 0 deletions actions/actions/setup-python/v5/commit-hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0a5c61591373683505ea898e09a3ea4f39ef2b9c
4 changes: 2 additions & 2 deletions docs/supported-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Click on a version to see the binding's code.
* [setup-go](https://github.com/actions/setup-go) - v3: [`SetupGoV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupGoV3.kt), v4: [`SetupGoV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupGoV4.kt), v5: [`SetupGoV5`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupGoV5.kt)
* [setup-java](https://github.com/actions/setup-java) - v2: [`SetupJavaV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV2.kt), v3: [`SetupJavaV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV3.kt), v4: [`SetupJavaV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV4.kt)
* [setup-node](https://github.com/actions/setup-node) - v2: [`SetupNodeV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV2.kt), v3: [`SetupNodeV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV3.kt), v4: [`SetupNodeV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV4.kt)
* [setup-python](https://github.com/actions/setup-python) - v2: [`SetupPythonV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV2.kt), v3: [`SetupPythonV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV3.kt), v4: [`SetupPythonV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV4.kt)
* [setup-python](https://github.com/actions/setup-python) - v2: [`SetupPythonV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV2.kt), v3: [`SetupPythonV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV3.kt), v4: [`SetupPythonV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV4.kt), v5: [`SetupPythonV5`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV5.kt)
* [stale](https://github.com/actions/stale) - v5: [`StaleV5`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV5.kt), v6: [`StaleV6`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV6.kt), v7: [`StaleV7`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV7.kt), v8: [`StaleV8`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV8.kt)
* [upload-artifact](https://github.com/actions/upload-artifact) - v2: [`UploadArtifactV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/UploadArtifactV2.kt), v3: [`UploadArtifactV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/UploadArtifactV3.kt)
* anmol098
Expand Down Expand Up @@ -142,6 +142,6 @@ Click on a version to see the binding's code.
Number of bindings available:

* counting by actions: 85
* counting each version separately: 140
* counting each version separately: 141

Actions [providing typings](https://github.com/typesafegithub/github-actions-typing/) (marked with ✅ on the above list): 18
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import kotlin.collections.toTypedArray
* [Action on GitHub](https://github.com/actions/setup-python)
*/
@Deprecated(
message = "This action has a newer major version: SetupPythonV4",
replaceWith = ReplaceWith("SetupPythonV4"),
message = "This action has a newer major version: SetupPythonV5",
replaceWith = ReplaceWith("SetupPythonV5"),
)
public data class SetupPythonV2 private constructor(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import kotlin.collections.toTypedArray
* [Action on GitHub](https://github.com/actions/setup-python)
*/
@Deprecated(
message = "This action has a newer major version: SetupPythonV4",
replaceWith = ReplaceWith("SetupPythonV4"),
message = "This action has a newer major version: SetupPythonV5",
replaceWith = ReplaceWith("SetupPythonV5"),
)
public data class SetupPythonV3 private constructor(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@file:Suppress(
"DataClassPrivateConstructor",
"UNUSED_PARAMETER",
"DEPRECATION",
)

package io.github.typesafegithub.workflows.actions.actions
Expand All @@ -12,6 +13,7 @@ import io.github.typesafegithub.workflows.domain.actions.Action
import io.github.typesafegithub.workflows.domain.actions.RegularAction
import java.util.LinkedHashMap
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
Expand All @@ -27,6 +29,10 @@ import kotlin.collections.toTypedArray
*
* [Action on GitHub](https://github.com/actions/setup-python)
*/
@Deprecated(
message = "This action has a newer major version: SetupPythonV5",
replaceWith = ReplaceWith("SetupPythonV5"),
)
public data class SetupPythonV4 private constructor(
/**
* Version range or exact version of Python or PyPy to use, using SemVer's version range syntax.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
// changes will be overwritten with the next binding code regeneration.
// See https://github.com/typesafegithub/github-workflows-kt for more info.
@file:Suppress(
"DataClassPrivateConstructor",
"UNUSED_PARAMETER",
)

package io.github.typesafegithub.workflows.actions.actions

import io.github.typesafegithub.workflows.domain.actions.Action
import io.github.typesafegithub.workflows.domain.actions.RegularAction
import java.util.LinkedHashMap
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.toList
import kotlin.collections.toTypedArray

/**
* Action: Setup Python
*
* Set up a specific version of Python and add the command-line tools to the PATH.
*
* [Action on GitHub](https://github.com/actions/setup-python)
*/
public data class SetupPythonV5 private constructor(
/**
* Version range or exact version of Python or PyPy to use, using SemVer's version range syntax.
* Reads from .python-version if unset.
*/
public val pythonVersion: String? = null,
/**
* File containing the Python version to use. Example: .python-version
*/
public val pythonVersionFile: String? = null,
/**
* Used to specify a package manager for caching in the default directory. Supported values:
* pip, pipenv, poetry.
*/
public val cache: SetupPythonV5.PackageManager? = null,
/**
* The target architecture (x86, x64) of the Python or PyPy interpreter.
*/
public val architecture: SetupPythonV5.Architecture? = null,
/**
* Set this option if you want the action to check for the latest available version that
* satisfies the version spec.
*/
public val checkLatest: Boolean? = null,
/**
* The token used to authenticate when fetching Python distributions from
* https://github.com/actions/python-versions. When running this action on github.com, the default
* value is sufficient. When running on GHES, you can pass a personal access token for github.com
* if you are experiencing rate limiting.
*/
public val token: String? = null,
/**
* Used to specify the path to dependency files. Supports wildcards or a list of file names for
* caching multiple dependencies.
*/
public val cacheDependencyPath: List<String>? = null,
/**
* Set this option if you want the action to update environment variables.
*/
public val updateEnvironment: Boolean? = null,
/**
* When 'true', a version range passed to 'python-version' input will match prerelease versions
* if no GA versions are found. Only 'x.y' version range is supported for CPython.
*/
public val allowPrereleases: Boolean? = null,
/**
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
*/
public val _customInputs: Map<String, String> = mapOf(),
/**
* Allows overriding action's version, for example to use a specific minor version, or a newer
* version that the binding doesn't yet know about
*/
public val _customVersion: String? = null,
) : RegularAction<SetupPythonV5.Outputs>("actions", "setup-python", _customVersion ?: "v5") {
public constructor(
vararg pleaseUseNamedArguments: Unit,
pythonVersion: String? = null,
pythonVersionFile: String? = null,
cache: SetupPythonV5.PackageManager? = null,
architecture: SetupPythonV5.Architecture? = null,
checkLatest: Boolean? = null,
token: String? = null,
cacheDependencyPath: List<String>? = null,
updateEnvironment: Boolean? = null,
allowPrereleases: Boolean? = null,
_customInputs: Map<String, String> = mapOf(),
_customVersion: String? = null,
) : this(pythonVersion=pythonVersion, pythonVersionFile=pythonVersionFile, cache=cache,
architecture=architecture, checkLatest=checkLatest, token=token,
cacheDependencyPath=cacheDependencyPath, updateEnvironment=updateEnvironment,
allowPrereleases=allowPrereleases, _customInputs=_customInputs,
_customVersion=_customVersion)

@Suppress("SpreadOperator")
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
*listOfNotNull(
pythonVersion?.let { "python-version" to it },
pythonVersionFile?.let { "python-version-file" to it },
cache?.let { "cache" to it.stringValue },
architecture?.let { "architecture" to it.stringValue },
checkLatest?.let { "check-latest" to it.toString() },
token?.let { "token" to it },
cacheDependencyPath?.let { "cache-dependency-path" to it.joinToString("\n") },
updateEnvironment?.let { "update-environment" to it.toString() },
allowPrereleases?.let { "allow-prereleases" to it.toString() },
*_customInputs.toList().toTypedArray(),
).toTypedArray()
)

override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)

public sealed class PackageManager(
public val stringValue: String,
) {
public object Pip : SetupPythonV5.PackageManager("pip")

public object Pipenv : SetupPythonV5.PackageManager("pipenv")

public object Poetry : SetupPythonV5.PackageManager("poetry")

public class Custom(
customStringValue: String,
) : SetupPythonV5.PackageManager(customStringValue)
}

public sealed class Architecture(
public val stringValue: String,
) {
public object X64 : SetupPythonV5.Architecture("x64")

public object X86 : SetupPythonV5.Architecture("x86")

public class Custom(
customStringValue: String,
) : SetupPythonV5.Architecture(customStringValue)
}

public class Outputs(
stepId: String,
) : Action.Outputs(stepId) {
/**
* The installed Python or PyPy version. Useful when given a version range as input.
*/
public val pythonVersion: String = "steps.$stepId.outputs.python-version"

/**
* A boolean value to indicate a cache entry was found
*/
public val cacheHit: String = "steps.$stepId.outputs.cache-hit"

/**
* The absolute path to the Python or PyPy executable.
*/
public val pythonPath: String = "steps.$stepId.outputs.python-path"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.typesafegithub.workflows

import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
import io.github.typesafegithub.workflows.actions.actions.GithubScriptV7
import io.github.typesafegithub.workflows.actions.actions.SetupPythonV4
import io.github.typesafegithub.workflows.actions.actions.SetupPythonV5
import io.github.typesafegithub.workflows.domain.JobOutputs
import io.github.typesafegithub.workflows.domain.Mode
import io.github.typesafegithub.workflows.domain.Permission
Expand Down Expand Up @@ -161,7 +161,7 @@ class RunOnGitHubTest : FunSpec({
},
)

val addAndCommit = uses(action = SetupPythonV4())
val addAndCommit = uses(action = SetupPythonV5())

uses(
name = "Some step consuming other step's output",
Expand Down

0 comments on commit 9f3d1ff

Please sign in to comment.