knl / niv-updater-action

A GitHub Action that creates meaningful pull requests with updates to your niv-managed dependencies, so you don't have to do menial chores.
BSD 3-Clause "New" or "Revised" License
29 stars 11 forks source link

Failure with SSH dependency #44

Closed nomeata closed 3 years ago

nomeata commented 3 years ago

This might be triggered due to permission issues, but the autoupdater falls over a SSH dependency somehow. Note the niv add / which looks odd:

2021-03-26T09:12:54.1986203Z + [[ -n ssh://git@github.com/dfinity/wasm-profiler ]]
2021-03-26T09:12:54.1987313Z + echo 'As this is a dependency fetched with SSH, trying to switch to https type'
2021-03-26T09:12:54.1988169Z ++ jq -jr '."wasm-profiler".branch // empty'
2021-03-26T09:12:54.1989097Z As this is a dependency fetched with SSH, trying to switch to https type
2021-03-26T09:12:54.2100349Z + niv_branch=main
2021-03-26T09:12:54.2101390Z + niv drop wasm-profiler
2021-03-26T09:12:54.2131976Z Dropping package: wasm-profiler
2021-03-26T09:12:54.2133425Z WARNING: Could not read nix/sources.nix
2021-03-26T09:12:54.2134487Z    ( nix/sources.nix: openBinaryFile: does not exist (No such file or directory) )
2021-03-26T09:12:54.2139261Z + niv add / -a rev=7cfb023e6f1d9a522fc56d24c35ace6d7f981f49 -a branch=main
2021-03-26T09:12:54.2166698Z Adding package /
2021-03-26T09:12:54.2167557Z   WARNING: Could not read nix/sources.nix
2021-03-26T09:12:54.2168431Z      ( nix/sources.nix: openBinaryFile: does not exist (No such file or directory) )
2021-03-26T09:12:54.2169493Z   FATAL: One or more packages failed to update:
2021-03-26T09:12:54.2170233Z   /: Update failed: Key could not be found: url_template
2021-03-26T09:12:54.2170884Z   CallStack (from HasCallStack):
2021-03-26T09:12:54.2172027Z     error, called at src/Niv/Update.hs:80:25 in niv-0.2.19-2iIhczlNd6n2o1L8BbaMTs:Niv.Update
2021-03-26T09:12:54.2173253Z ERROR: ExitFailure 1
2021-03-26T09:12:54.2182075Z + rm -f /tmp/tmp.agkRAPKePE
2021-03-26T09:12:54.2225088Z child_process.js:642
2021-03-26T09:12:54.2225813Z     throw err;
2021-03-26T09:12:54.2226508Z     ^
2021-03-26T09:12:54.2227707Z 
2021-03-26T09:12:54.2228964Z Error: Command failed: /home/runner/work/_actions/knl/niv-updater-action/v9/niv-updater
2021-03-26T09:12:54.2230096Z     at checkExecSyncError (child_process.js:621:11)
2021-03-26T09:12:54.2230972Z     at execFileSync (child_process.js:639:15)
2021-03-26T09:12:54.2232222Z     at Object.<anonymous> (/home/runner/work/_actions/knl/niv-updater-action/v9/main.js:3:1)
2021-03-26T09:12:54.2233296Z     at Module._compile (internal/modules/cjs/loader.js:959:30)
2021-03-26T09:12:54.2234301Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2021-03-26T09:12:54.2235310Z     at Module.load (internal/modules/cjs/loader.js:815:32)
2021-03-26T09:12:54.2236257Z     at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2021-03-26T09:12:54.2237317Z     at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
2021-03-26T09:12:54.2238431Z     at internal/main/run_main_module.js:17:11 {
2021-03-26T09:12:54.2239286Z   status: 1,
2021-03-26T09:12:54.2239727Z   signal: null,
2021-03-26T09:12:54.2240177Z   output: [ null, null, null ],
2021-03-26T09:12:54.2240649Z   pid: 1453,
2021-03-26T09:12:54.2241024Z   stdout: null,
2021-03-26T09:12:54.2241433Z   stderr: null
2021-03-26T09:12:54.2241784Z }
2021-03-26T09:12:54.2300758Z Cleaning up orphan processes

(This is using v9)

nomeata commented 3 years ago

Maybe these lines should allow dashes in the URL parts? (([\w_.]+?) might be too strict)

            dep_owner="$(echo "$github_ssh" | perl -nle 'print $1 if m/[:\/]([\w-]{1,39})\/([\w_.]+?)(?:\.git)?$/;')"
            dep_repo="$(echo "$github_ssh" | perl -nle 'print $2 if m/[:\/]([\w-]{1,39})\/([\w_.]+?)(?:\.git)?$/;')"
knl commented 3 years ago

Hi @nomeata, you're absolutely right, the regex is too strict.

To unblock you, I'm going to make it more lenient and add - in the list. Then, next week when I find time, I'm going to take a better look and maybe completely ditch these regexes and the dependency on perl. As the comment above those lines says, if it's in sources.json, it has to be correct.