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

Github actions are not upgraded #192

Open
kimmoahola opened this issue Nov 21, 2022 · 14 comments
Open

Github actions are not upgraded #192

kimmoahola opened this issue Nov 21, 2022 · 14 comments

Comments

@kimmoahola
Copy link

I have the following GHA yml file:

name: TEST
on:
  push:
    branches:
    - "*"
jobs:
  lint:
    steps:
    - uses: actions/checkout@v2


  lint2:
    steps:
    - uses: actions/[email protected]

My deps.edn looks like this:

:deps {...

:aliases {
  :outdated {:replace-deps {com.github.liquidz/antq {:mvn/version "2.2.962"}}
             :main-opts ["-m" "antq.core" "--upgrade" "--force" "--skip=pom"]}
}

When I run antq it will output:

|                             :file |                                         :name | :current | :latest |
|-----------------------------------+-----------------------------------------------+----------+---------|
|        .github/workflows/test.yml |                              actions/checkout |       v2 |  v3.1.0 |
|                                   |                              actions/checkout |   v3.0.2 |  v3.1.0 |

Available changes:
- https://github.com/actions/checkout/blob/v3.1.0/CHANGELOG.md
Upgraded actions/checkout 'v2' to 'v3' in .github/workflows/test.yml.
Upgraded actions/checkout 'v3.0.2' to 'v3.1.0' in .github/workflows/test.yml.

But it will not update those two checkout steps.

And another issue is that the test.yml will get bogus content. The lint2 job get duplicated:

name: TEST
on:
  push:
    branches:
    - "*"
jobs:
  lint:
    steps:
    - uses: actions/checkout@v2


  lint2:
    steps:
    - uses: actions/[email protected]

  lint2:
    steps:
    - uses: actions/[email protected]

  lint2:
    steps:
    - uses: actions/[email protected]

  lint2:
    steps:
    - uses: actions/[email protected]

The original test.yml has two empty lines before lint2:. If I remove the other empty line then the content is not duplicated (but steps are still not upgraded).

If I add two spaces to the beginning of the lines - uses: then antq will upgrade those steps. The original test.yml file is valid yaml (maybe not properly formated, but still valid).

@liquidz
Copy link
Owner

liquidz commented Nov 21, 2022

@kimmoahola Thanks for your reporting!
It should be a problem of liquidz/rewrite-indented.

I didn't have a good library to rewrite yaml, so I made a simple one.
This library rewrites texts based on indentations only, so the validity of yaml is not checked.

To fix this problem, we need to find or create a library that correctly parses and rewrites yaml.

FYI, If antlr had a yaml grammer, I would have wanted to use it.
https://github.com/antlr/grammars-v4

@seancorfield
Copy link
Contributor

Just coming here to report something very similar -- I have:

      - name: Clojure CLI
        uses: DeLaGuardo/setup-clojure@master
        with:
          tools-deps: '1.11.1.1208'

antq spots that it is outdated and offers to upgrade it to 1.11.1.1347 but answering y produces no change in the file.

@liquidz
Copy link
Owner

liquidz commented Jun 16, 2023

@seancorfield Oh, I could reproduce the problem. Thanks!

@liquidz
Copy link
Owner

liquidz commented Jun 16, 2023

It is a bug in liquidz/rewrite-indented.
I'll fix :)

@liquidz
Copy link
Owner

liquidz commented Jun 17, 2023

@seancorfield I've fixed the problem in v2.5.1095.
By the way, tools-deps is deprecated and antq does not support.
https://github.com/DeLaGuardo/setup-clojure/blob/1c76ab0e154379260d7a6ea16b413679abe46785/action.yml#L13-L14

Please use cli instead of tools-deps.

@seancorfield
Copy link
Contributor

Good to know -- thanks!

@seancorfield
Copy link
Contributor

Works beautifully, now I've switched to cli: -- thank you!

@devurandom
Copy link

I still encounter the original issue author's problem: When a workflow contains multiple references to actions/checkout@... antq will only update one of them (the first?). It will detect that the action could be updated, but confirming with y results in no changes in the file.

@liquidz
Copy link
Owner

liquidz commented Oct 30, 2023

@devurandom Could you show me your YAML file?
I'll try to reproduce the problem.

@devurandom
Copy link

devurandom commented Oct 30, 2023

I am able to reproduce it with this file:

jobs:
  example:
    steps:
      - uses: actions/checkout@v4
      - uses: actions/checkout@v3
        with:
          repository: antq/example
❯ tree -a
.
└── .github
    └── workflows
        └── antq-mwe.yml

3 directories, 1 file

❯ clj -Tantq outdated :upgrade true
[##################################################] 1/1
| :file                          | :name            | :current | :latest |
|--------------------------------+------------------+----------+---------|
| .github/workflows/antq-mwe.yml | actions/checkout | v3       | v4.1.1  |

Available changes:
- https://github.com/actions/checkout/blob/v4.1.1/CHANGELOG.md

Do you want to upgrade actions/checkout 'v3' to 'v4' in .github/workflows/antq-mwe.yml (y/n): y
Upgraded actions/checkout 'v3' to 'v4' in .github/workflows/antq-mwe.yml.

antq says "upgraded", but the content of the file stays exactly the same.

@liquidz
Copy link
Owner

liquidz commented Oct 30, 2023

@devurandom Thanks! I could reproduce the problem.
I'll fix :)

liquidz added a commit that referenced this issue Dec 1, 2023
liquidz added a commit that referenced this issue Dec 1, 2023
@liquidz
Copy link
Owner

liquidz commented Dec 1, 2023

@devurandom Sorry for late work.
I've fixed the problem in dev branch.
Could you try?

@devurandom
Copy link

devurandom commented Dec 4, 2023

I've fixed the problem in dev branch. Could you try?

Thanks a lot! I tried 020a847 and it worked. :)

@liquidz
Copy link
Owner

liquidz commented Dec 10, 2023

@devurandom Thanks for your confirmation!
Just released 2.7.1147

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

No branches or pull requests

4 participants