oranda icon indicating copy to clipboard operation
oranda copied to clipboard

Link checker github action step is broken

Open konstin opened this issue 1 year ago • 2 comments

Workflow file: https://github.com/konstin/virtualenv-rs/blob/b68641227aef9e3dbccad15f3d8407c1aceaa109/.github/workflows/web.yml Run: https://github.com/konstin/gourgeist/actions/runs/6355674453/job/17264084654 Error message:

Run /home/runner/work/_actions/untitaker/hyperlink/0.1.29/scripts/hyperlink-bin /tmp/public/ --sources docs/ --github-actions
[...]
Reading files
Checking 34 links from 11 files (4 documents)
Found some broken links, reading source files
Error: IO error for operation on docs/: No such file or directory (os error 2)

I can reproduce this locally:

$ oranda build
↪ >o_o< INFO: Building components: artifacts, changelog
✓ >o_o< SUCCESS: Your site build is located in `public`.
$ mkdir /tmp/public/ && cp -R public /tmp/public/oranda
$ npx @untitaker/hyperlink /tmp/public/ --sources docs/
Reading files
Checking 34 links from 11 files (4 documents)
Found some broken links, reading source files
Error: IO error for operation on docs/: No such file or directory (os error 2)

Caused by:
    No such file or directory (os error 2)

konstin avatar Sep 29 '23 18:09 konstin

The error appears to be still happening.

Repro steps (emulate the CI):

$ oranda --version
oranda 0.5.0
$ oranda build
↪ >o_o< INFO: Building components: artifacts, changelog
✓ >o_o< SUCCESS: Your site build is located in `public`.
$ mkdir /tmp/public/ && cp -R public /tmp/public/oranda
$ hyperlink /tmp/public/
Reading files
Checking 34 links from 11 files (4 documents)
/tmp/public/oranda/artifacts/index.html
  error: bad link /
  error: bad link /artifacts
  error: bad link /artifacts.js
  error: bad link /changelog
  error: bad link /favicon.ico
  error: bad link /<project>-installer.ps1.txt
  error: bad link /<project>-installer.sh.txt
  error: bad link /oranda-v0.5.0.css

/tmp/public/oranda/changelog/index.html
  error: bad link /
  error: bad link /artifacts
  error: bad link /artifacts.js
  error: bad link /changelog
  error: bad link /changelog.rss
  error: bad link /favicon.ico
  error: bad link /oranda-v0.5.0.css

/tmp/public/oranda/changelog/v0.1.0/index.html
  error: bad link /
  error: bad link /artifacts
  error: bad link /changelog
  error: bad link /favicon.ico
  error: bad link /oranda-v0.5.0.css

/tmp/public/oranda/index.html
  error: bad link /
  error: bad link /artifacts
  error: bad link /artifacts.js
  error: bad link /changelog
  error: bad link /favicon.ico
  error: bad link /<project>-installer.ps1.txt
  error: bad link /<project>-installer.sh.txt
  error: bad link /oranda-v0.5.0.css

Found 32 bad links

The correct command seems to be:

$ hyperlink /tmp/public/oranda
Reading files
Checking 34 links from 11 files (4 documents)
Found 0 bad links

m-lamonaca avatar Oct 18 '23 10:10 m-lamonaca

On further experimentation I found that this does not work if build.prefix_path or build.dist_dir are set.

The correct command is probably:

$ mkdir /tmp/{build.dist_dir}/{build.path_prefix} 
$ cp -R {build.dist_dir} /tmp/{build.dist_dir}/{build.path_prefix}

# This is optional if build.path_prefix is empty/default but is necessary otherwise
# since the hrefs will be like /{build.path_prefix}/artifacts.js
$ cp {build.dist_dir}/index.html /tmp/{build.dist_dir}/index.html

$ hyperlink /tmp/{build.dist_dir}/{build.path_prefix}

Here you can find an example of a patched workflow that works.

Unfortunately, I have zero ideas on how to actually implement this, sorry.

m-lamonaca avatar Oct 18 '23 12:10 m-lamonaca