Upgrade does not work for github actions for some valid yaml indentations
Setup
Given this valid .github/workflows/test1.yml:
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
testing:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 23
- name: Install Clojure Tools
uses: DeLaGuardo/[email protected]
with:
lein: 'latest'
Setup for comparison
git init
git add .github
Repro
If I run:
clojure -Sdeps '{:deps {com.github.liquidz/antq {:mvn/version "2.11.1276"}}}' -M -m antq.core --upgrade --force
At the time of this writing, we see the following output:
[##################################################] 3/3
| :file | :name | :current | :latest |
|-----------------------------|--------------------------|----------|---------|
| .github/workflows/test1.yml | DeLaGuardo/setup-clojure | 13.1 | 13.2 |
| | actions/checkout | v3 | v4.2.2 |
Available changes:
- https://github.com/DeLaGuardo/setup-clojure/compare/13.1...13.2
- https://github.com/actions/checkout/blob/v4.2.2/CHANGELOG.md
Upgraded actions/checkout 'v3' to 'v4' in .github/workflows/test1.yml.
Upgraded DeLaGuardo/setup-clojure '13.1' to '13.2' in .github/workflows/test1.yml.
Which seems good, but if I run git diff
Expected Behaviour
I would expect git diff to show the changes antq applied.
Actual Behaviour
Git diff shows that no changes have been applied.
Diagnosis
If we replace .github/workflows/test1.yml with a slightly different indentation:
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
testing:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 23
- name: Install Clojure Tools
uses: DeLaGuardo/[email protected]
with:
lein: 'latest'
And then run git add .github to prepare for our diff later.
And then rerun antq as above, we get the same output.
But now, if we git diff we see what we'd expect:
diff --git a/.github/workflows/test1.yml b/.github/workflows/test1.yml
index d2717b5..987624f 100644
--- a/.github/workflows/test1.yml
+++ b/.github/workflows/test1.yml
@@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
@@ -23,6 +23,6 @@ jobs:
java-version: 23
- name: Install Clojure Tools
- uses: DeLaGuardo/[email protected]
+ uses: DeLaGuardo/[email protected]
with:
lein: 'latest'
To question
Is the yaml I tested with valid? Yes, I think so. I've happened to use this indentation on other projects I help to maintain, for example etaoin.
Next Steps
I'd be happy to take a peek and work on a fix if that is interesting to you.
@lread Thanks for your reporting!
I think it's the same issue as the one below.
https://github.com/liquidz/antq/issues/192#issuecomment-1321556248
I haven't recently looked into ways to properly parse and rewrite YAML, so there might be a better approach available now.
Ah, yes, I see. YAML is oh so complicated. Antq parses (or maybe more technically, evaluates!) YAML with clj-yaml to discover deps, but when upgrading regexes are used.
For the near term, I could take a peek at those regexes and see what I can do.
It also might be interesting for antq to emit an error when a YAML upgrade does not effect any change. Maybe:
UNEXPECTED failed to upgrade actions/checkout 'v3' to 'v4' in .github/workflows/test1.yml
This way users could raise an issue for any edge cases the regexes miss.