-
Notifications
You must be signed in to change notification settings - Fork 471
Use version ranges for actions to not use stale cache entries #2126
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
Use version ranges for actions to not use stale cache entries #2126
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2126 +/- ##
=========================================
Coverage 81.92% 81.92%
Complexity 4728 4728
=========================================
Files 463 463
Lines 14764 14764
Branches 1867 1867
=========================================
Hits 12095 12095
Misses 1980 1980
Partials 689 689 🚀 New features to boost your workflow:
|
What is the effect of this? Will this now be checked every time it is executed? |
That's not so much different to before. The problem with not using version ranges is, that for Maven (and thus the main.kts script as it uses the same resolution engine) version that do not end in So assume you execute the script on your machine today, that packs By using the version range the Kotlin script is using the actual latest version so uses the actual |
1b053b0
to
3ea0cad
Compare
3ea0cad
to
6edf86c
Compare
I understand the problem and I don't have any "better" solution to that, however using version ranges in dependencies generate an additional moving block(s) which might make troubleshooting of accidentally misbehaving job/workflow even harder. In addition, looking at the tj-actions/changed-files attack, it might be good to use hashes for (especially unofficial) actions. I wanted to report a feature request to print also a version in YAML when using a |
You might misunderstand this PR. Whether to instead use a concrete version or pin to a specific hash is a completely different topic. The issue you linked is - as far as I understand it - more to have it in a way that Renovate can update it. |
This is how you for example could have codecov with hash and version printed right now, but as I said, Renovate would not anymore work like expected with it and it is not really the topic here: diff --git a/.github/workflows/common.main.kts b/.github/workflows/common.main.kts
index 48eda517c0..7aeaae5b8e 100755
--- a/.github/workflows/common.main.kts
+++ b/.github/workflows/common.main.kts
@@ -19,17 +19,47 @@
@file:Repository("https://repo.maven.apache.org/maven2/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.3.0")
+import io.github.typesafegithub.workflows.domain.Concurrency
import io.github.typesafegithub.workflows.domain.Job
import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.actions.Action.Outputs
import io.github.typesafegithub.workflows.domain.actions.LocalAction
+import io.github.typesafegithub.workflows.domain.triggers.Trigger
import io.github.typesafegithub.workflows.dsl.JobBuilder
import io.github.typesafegithub.workflows.dsl.WorkflowBuilder
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets
import io.github.typesafegithub.workflows.dsl.expressions.expr
+import io.github.typesafegithub.workflows.dsl.workflow
+import java.io.File
import java.util.Properties
+fun workflowWithCommentedHashes(
+ name: String,
+ on: List<Trigger>,
+ sourceFile: File? = null,
+ concurrency: Concurrency? = null,
+ block: WorkflowBuilder.() -> Unit,
+) {
+ workflow(
+ name = name,
+ on = on,
+ sourceFile = sourceFile,
+ concurrency = concurrency,
+ block = block,
+ )
+ sourceFile!!
+ .let { it.resolveSibling(it.nameWithoutExtension.substringBeforeLast('.') + ".yaml") }
+ .apply {
+ readText()
+ .replace(
+ "@ad3126e916f78f00edff4ed0317cf185271ccc2d'",
+ "@ad3126e916f78f00edff4ed0317cf185271ccc2d' #5.4.2"
+ )
+ .also { writeText(it) }
+ }
+}
+
val GRADLE_ENTERPRISE_ACCESS_KEY by secrets
val commonCredentials = mapOf(
diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts
index 59f1f25895..668936063c 100755
--- a/.github/workflows/release.main.kts
+++ b/.github/workflows/release.main.kts
@@ -24,19 +24,18 @@
@file:Repository("https://bindings.krzeminski.it/")
@file:DependsOn("actions:checkout:v4")
-@file:DependsOn("codecov:codecov-action:v5")
+@file:DependsOn("codecov:codecov-action:ad3126e916f78f00edff4ed0317cf185271ccc2d")
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.actions.Checkout.FetchDepth
-import io.github.typesafegithub.workflows.actions.codecov.CodecovAction
+import io.github.typesafegithub.workflows.actions.codecov.CodecovAction_Untyped
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets
import io.github.typesafegithub.workflows.dsl.expressions.expr
-import io.github.typesafegithub.workflows.dsl.workflow
-workflow(
+workflowWithCommentedHashes(
name = "Build and Release Spock",
on = listOf(
Push(
@@ -97,8 +96,8 @@ workflow(
)
uses(
name = "Upload to Codecov.io",
- action = CodecovAction(
- failCiIfError = true
+ action = CodecovAction_Untyped(
+ failCiIfError_Untyped = "true"
)
)
} |
No description provided.