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

[Bug] step-1 ("Execute script") of "Check YAML consistency" job is broken if generated from project root #1192

Closed
LouisCAD opened this issue Dec 15, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@LouisCAD
Copy link
Contributor

Action

I ran my workflow generating script from the root folder using the following shell command:

./.github/workflows/publish-plugins.main.kts

Expected

The same content is generated as if I run as ./publish-plugins.main.kts from the .github/workflows directory.

Actual

run: 'rm ''.github/workflows/publish-plugins.yaml'' && ''publish-plugins.main.kts'''

was generated instead of

run: 'rm ''.github/workflows/publish-plugins.yaml'' && ''.github/workflows/publish-plugins.main.kts'''.

It failed on GitHub at the "Check YAML consistency" job, step "Execute script" because the path to the script was wrong.

https://github.com/Splitties/gradle-dependencies-dsl/actions/runs/7227552380/job/19695431873

Workaround

I ran the script it again after running cd .github/workflows, and committed the changes: Splitties/gradle-dependencies-dsl@c273d68

Library version

v1.7.0

@LouisCAD LouisCAD added the bug Something isn't working label Dec 15, 2023
@krzema12
Copy link
Member

krzema12 commented Dec 16, 2023

Was it working fine for you in the past?

Generally it should already work the same way in both cases. See e. g. the workflows in this repo:

run: 'rm ''.github/workflows/build.yaml'' && ''.github/workflows/build.main.kts'''

If the bug was reproducible in this case, the consistency check would produce a different YAML here.

In the library, we build this path here:

@Vampire do you have a minute to take a look? I'm having a busy time.
The first step is to try to reproduce using @LouisCAD's project.

@LouisCAD
Copy link
Contributor Author

I think it's the first time I'm running it manually from a terminal where the working directory is the project root.

All the other times, I was running it with the run button in IntelliJ (it is lacking in Fleet 😅), and that leads to it being run from the script directory in a terminal tab, where there's no bug.

@krzema12
Copy link
Member

@LouisCAD could you first check if you aren't affected by this issue with the Kotlin script cache? https://youtrack.jetbrains.com/issue/KT-64367/

@krzema12 krzema12 self-assigned this Dec 16, 2023
@krzema12
Copy link
Member

I got a similar result to yours with such reproduction:

piotr@Piotrs-MacBook-Air gradle-dependencies-dsl % .github/workflows/publish-plugins.main.kts 
piotr@Piotrs-MacBook-Air gradle-dependencies-dsl % git st
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
piotr@Piotrs-MacBook-Air gradle-dependencies-dsl % cd .github/workflows 
piotr@Piotrs-MacBook-Air workflows % ./publish-plugins.main.kts 
piotr@Piotrs-MacBook-Air workflows % git st
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   publish-plugins.yaml

no changes added to commit (use "git add" and/or "git commit -a")
piotr@Piotrs-MacBook-Air workflows % git diff
diff --git a/.github/workflows/publish-plugins.yaml b/.github/workflows/publish-plugins.yaml
index a2b4630..9e2877b 100644
--- a/.github/workflows/publish-plugins.yaml
+++ b/.github/workflows/publish-plugins.yaml
@@ -1,4 +1,4 @@
-# This file was generated using Kotlin DSL (.github/workflows/publish-plugins.main.kts).
+# This file was generated using Kotlin DSL (.github/workflows/.github/workflows/publish-plugins.main.kts).
 # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
 # Generated with https://github.com/typesafegithub/github-workflows-kt
 
@@ -22,7 +22,7 @@ jobs:
       uses: 'actions/checkout@v4'
     - id: 'step-1'
       name: 'Execute script'
-      run: 'rm ''.github/workflows/publish-plugins.yaml'' && ''.github/workflows/publish-plugins.main.kts'''
+      run: 'rm ''.github/workflows/publish-plugins.yaml'' && ''.github/workflows/.github/workflows/publish-plugins.main.kts'''
     - id: 'step-2'
       name: 'Consistency check'
       run: 'git diff --exit-code ''.github/workflows/publish-plugins.yaml'''
piotr@Piotrs-MacBook-Air workflows % rm -rf ~/Library/Caches/main.kts.compiled.cache/
piotr@Piotrs-MacBook-Air workflows % ./publish-plugins.main.kts                      
piotr@Piotrs-MacBook-Air workflows % git st
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
piotr@Piotrs-MacBook-Air workflows % 

@LouisCAD please confirm if cleaning the cache makes the script work correctly.

@krzema12
Copy link
Member

TODO in this issue: describe https://youtrack.jetbrains.com/issue/KT-64367/ in the FAQ.

@krzema12
Copy link
Member

Resolving as not really a bug with the library. Please reopen if needed.

@krzema12 krzema12 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants