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]: Nim installation is too long! #483

Closed
Ethosa opened this issue Jun 28, 2024 · 38 comments
Closed

[Bug]: Nim installation is too long! #483

Ethosa opened this issue Jun 28, 2024 · 38 comments
Assignees
Labels
bug Something isn't working

Comments

@Ethosa
Copy link

Ethosa commented Jun 28, 2024

What happened?

When gh action was run this action is do nothing(?) too long.

Relevant log output

No response

Actions log url

https://github.com/HapticX/happyx/actions/runs/9716162111

and many actions before

@Ethosa Ethosa added the bug Something isn't working label Jun 28, 2024
@Ethosa
Copy link
Author

Ethosa commented Jun 28, 2024

What is noteworthy is that when installing Nim without this action, it is installed quite smartly

@Ethosa
Copy link
Author

Ethosa commented Jun 28, 2024

this action:
image

without action:
image

jiro4989 added a commit that referenced this issue Jun 29, 2024
* fix: bump minor node version

* fix: slow install
@jiro4989
Copy link
Owner

@Ethosa thanks. I added a temporary patch. Please try using setup-nim-action 1.5.2 or later.
The installation will be completed in about 10 seconds.

@fox0430
Copy link
Contributor

fox0430 commented Jul 4, 2024

In my environment, Nim 1.x is fast but Nim 2.x is still slow...

1.x - about 20 seconds
2.x - about 6 minutes

https://github.com/fox0430/moe/actions/runs/9798974578/job/27061052837

Do I need additional configs?

@jiro4989
Copy link
Owner

jiro4989 commented Jul 4, 2024

I'm not sure what the cause is. It's suddenly become slow even though I haven't made any changes.

Using choosenim on a job is fast, so there may be a problem with the Node runtime for GitHub Actions.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 4, 2024

I know that the installation is very slow on a Mac runner. #487

But no good solution has been found yet.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 5, 2024

@Ethosa @fox0430 I will be making a major change to setup-nim-action.

Until now, setup-nim-action depended on choosenim.
However, it seems that installing using choosenim has become very slow.
So I will change the way to install Nim without using choosenim.

#491

I created a new version v2-beta, and testing it now.

I tested setup-nim-action v2-beta on my repositories:

The tests complete in under 30 seconds on Ubuntu and Windows.
The tests complete in under 6 minutes on MacOS.

This is BREAKING_CHANGES.
So I need your help.

Please re-run your CI tests with setup-nim-action v2-beta.

      - uses: jiro4989/setup-nim-action@v2-beta
        with:
          nim-version: 2.0.8
          repo-token: ${{ secrets.GITHUB_TOKEN }}

@fox0430
Copy link
Contributor

fox0430 commented Jul 5, 2024

@jiro4989

Thank you for a great job. So, I tried it and it seems to fail. Do you know if I need to do anything?

fox0430/moe#2086

https://github.com/fox0430/moe/actions/runs/9810738115/job/27091529854

@jiro4989
Copy link
Owner

jiro4989 commented Jul 5, 2024

Hmm, please try to delete cache action.

https://github.com/fox0430/moe/actions/runs/9810738115/job/27091529854#step:3:1

@fox0430
Copy link
Contributor

fox0430 commented Jul 5, 2024

@jiro4989

It works! Thank you! And, devel is not supported yet, is it?

@jiro4989
Copy link
Owner

jiro4989 commented Jul 5, 2024

Yes, devel is not supported yet. I will do it soon.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 5, 2024

@fox0430 I fixed devel version support.
Please re-run your setup-nim-action@v2-beta CI.

@fox0430
Copy link
Contributor

fox0430 commented Jul 5, 2024

@jiro4989

Passed all and macOS and stable (2.0.8) are much faster! Thank you!

https://github.com/fox0430/moe/actions/runs/9810836173

@jiro4989
Copy link
Owner

jiro4989 commented Jul 5, 2024

@fox0430 Thanks for your help👍
It's too late for that today so I'll release v2 tomorrow.
And I will write v2 documentations and migrations.

jiro4989 added a commit that referenced this issue Jul 6, 2024
* fix: mac slow install

* feat: composite action

* fix: no

* add env

* Revert "fix: no"

This reverts commit bbe060a.

* add: script

* fix path

* latest install

* stable install

* WIP: testcase

* windows

* windows test

* fix PATH

* debug

* quite

* fix if

* debug

* pwsh

* mkdir

* add comment

* fix description

* add macos test

* uname

* fix arch

* fix mac os

* fix os

* fix

* build for mac

* comment out

* fix repo token

* fix auth

* sh

* debug

* fix build

* del: ls

* change build options

* add macos-latest test

* add info log

* del: unused inputs

* feat: 1.x pattern

* add tests

* add: print version

* del: too old version

* Revert "del: unused inputs"

This reverts commit 45b4264.

* fix: change message

* del: unused ci tests

* docs: update setup-nim-action version to v2-beta

* fix: install_nim.sh path

* feat: build devel nim compiler

* ci: add devel test

* fix: description of nim-install-directory parameter

* docs: v2-beta to v2

* docs: migration to v2 from v1

* docs: v2 section

* docs: fix link

* docs: add issues link

* docs: change cache key

* docs: update devel usage

* docs: remove choosenim cache

* docs: add QA section
@jiro4989
Copy link
Owner

jiro4989 commented Jul 6, 2024

@Ethosa @fox0430 v2 version released.
https://github.com/jiro4989/setup-nim-action/releases/tag/v2

Please use jiro4989/setup-nim-action@v2.

See: Migration guide

@Ethosa
Copy link
Author

Ethosa commented Jul 7, 2024

@jiro4989 https://github.com/HapticX/happyx/actions/runs/9825359062/job/27125416903

/home/runner/work/_temp/b27fe6ae-1169-4182-9847-f39343eeb675.sh: line 4: /home/runner/.nimble/bin/nim: No such file or directory

@Ethosa
Copy link
Author

Ethosa commented Jul 7, 2024

@jiro4989
Copy link
Owner

jiro4989 commented Jul 7, 2024

try using not-fullpath nim command. nim exists in PATH. (Log)

        run: |
          cd tests
          for file in $(ls -v testc*.nim); do
            echo "###===--- C Test for " $file " via HttpBeast ---===###"
-           /home/runner/.nimble/bin/nim c -d:beast -d:debug --hints:off --warnings:off $file
+           nim c -d:beast -d:debug --hints:off --warnings:off $file
          done
        shell: bash

And change cache key, and delete choosenim directory.

      - uses: actions/cache@v4
        with:
          path: |
            ~/.nimble
-           ~/.choosenim
-         key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
+         key: ${{ runner.os }}-nimble-v2-${{ hashFiles('*.nimble') }}

@Ethosa
Copy link
Author

Ethosa commented Jul 7, 2024

@jiro4989
Copy link
Owner

jiro4989 commented Jul 7, 2024

It looks that you didn't call setup-nim-action in the workflow.

  1. actions/checkout@v4
  2. actions/cache@v4
  3. jiro4989/setup-nim-action@v2 <-- Need here
  4. Build C tests

image

@Ethosa
Copy link
Author

Ethosa commented Jul 7, 2024

setup was in dependencies job

@jiro4989
Copy link
Owner

jiro4989 commented Jul 7, 2024

add cache path to dependencies job.

      - uses: actions/cache@v4
        with:
          path: |
            ~/.nimble
+           .nim_runtime
          key: ${{ runner.os }}-nimble-v2-${{ hashFiles('*.nimble') }}

and set PATH to after jobs.

      - uses: actions/cache@v4
        with:
          path: |
            ~/.nimble
+           .nim_runtime
          key: ${{ runner.os }}-nimble-v2-${{ hashFiles('*.nimble') }}
      - name: Build C tests (Default HTTP Server) ⚡
        run: |
+         export PATH=$PATH:$PWD/.nim_runtime/bin
          cd tests
          echo "###===--- Default for" $file "---===###"
          for file in $(ls -v testc*.nim); do
            echo "###===--- C Test for " $file " via stdlib ---===###"
            nim c -d:debug --hints:off --warnings:off $file
          done
        shell: bash

@Ethosa
Copy link
Author

Ethosa commented Jul 7, 2024

@jiro4989 thanks you!

@dlesnoff
Copy link

dlesnoff commented Jul 8, 2024

The checks are failing in TheAlgorithms repository for the v2 upgrade:

Run jiro4989/setup-nim-action@v2
Run "/home/runner/work/_actions/jiro4989/setup-nim-action/v2/install_nim.sh" \
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   109  100   109    0     0   1037      0 --:--:-- --:--:-- --:--:--  1038
jq: error (at <stdin>:5): Cannot index string with string "ref"
Mon Jul  8 05:02:48 UTC 2024 [INFO] install nim 
tar: This does not look like a tar archive
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Error: Process completed with exit code 2.

Are similar changes as those recommended to Ethosa necessary for this upgrade?

EDIT: Sorry, I did not check the README.md beforehand.
EDIT2: Checked but does not seem related to this issue.

@vil02
Copy link
Contributor

vil02 commented Jul 8, 2024

@dlesnoff: when nim-version is set to stable (i.e. its default value), then the download_url becomes https://nim-lang.org/download/nim-stable-linux_x64.tar.xz, which does not lead to an existing file.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

@dlesnoff Did you set a repo-token parameter?

  - uses: jiro4989/setup-nim-action@v2
    with:
      nim-version: '2.0.0' # default is 'stable'
+     repo-token: ${{ secrets.GITHUB_TOKEN }}

repo-token is using for Rate limiting.

jq: error (at :5): Cannot index string with string "ref"

I think that GitHub API reached Rate limit.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

@dlesnoff stable bug was fixed ( #497 ).
Please re-run setup-nim-action@v2.

@dlesnoff
Copy link

dlesnoff commented Jul 8, 2024

It works but I have to change all potentially destructive instructions to exclude the .nim_runtime directory. Destructive instructions being nim prettyfy or git clean.

Wasn't it possible to put the nim directory in another separate temporary directory like runner.temp (is it writable?, see: actions/toolkit#518).

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

You can use nim-install-directory if you want to change nim directory.

  - uses: jiro4989/setup-nim-action@v2
    with:
      nim-version: '2.0.0' # default is 'stable'
      repo-token: ${{ secrets.GITHUB_TOKEN }}
+     nim-install-directory: ${{ runner.temp }}

@dlesnoff
Copy link

dlesnoff commented Jul 8, 2024

Thanks!
I'll try that!

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

If ${{ runner.temp }} fails, try ${{ runner.temp }}/nim_runtime too.

@dlesnoff
Copy link

dlesnoff commented Jul 8, 2024

Both options fail. Shouldn't these lines use the nim-install-directory variable ?

  echo "$PWD//home/runner/work/_temp/bin" >> "$GITHUB_PATH"
  echo "$HOME/.nimble/bin" >> "$GITHUB_PATH"

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

OMG, this is bug. I will fix it🙇

@jiro4989
Copy link
Owner

jiro4989 commented Jul 8, 2024

@dlesnoff Added parent-nim-install-directory parameter.
We can change install destination directory.

  - uses: jiro4989/setup-nim-action@v2
    with:
      nim-version: '2.0.0' # default is 'stable'
      repo-token: ${{ secrets.GITHUB_TOKEN }}
+     parent-nim-install-directory: ${{ runner.temp }}

This example installs nim to /home/runner/work/_temp/.nim_runtime.

@dlesnoff
Copy link

dlesnoff commented Jul 8, 2024

Still not there!
When re-running job, nim full path is empty! https://github.com/TheAlgorithms/Nim/actions/runs/9840934507/job/27176546752#step:3:38

@jiro4989
Copy link
Owner

jiro4989 commented Jul 9, 2024

@dlesnoff Did you solve?

#499 (comment)

The issues ( #483 ) are getting long, so I would like to close them soon.

@dlesnoff
Copy link

dlesnoff commented Jul 9, 2024

You can close it. It was an error on my side sorry.
I did not notice that you changed nim-install-directory to parent-nim-install-directory.

@jiro4989
Copy link
Owner

jiro4989 commented Jul 9, 2024

OK. The slow installation issue has been resolved, so I will close this issue.

Please open a new issue if anyone find any issues with v2 version.

@jiro4989 jiro4989 closed this as completed Jul 9, 2024
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

5 participants