Skip to content

ci: update caddy job to use GitHub Releases #13296

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

Closed
wants to merge 1 commit into from

Conversation

Ayesh
Copy link
Member

@Ayesh Ayesh commented Jan 31, 2024

The caddyserver.com download page is unreliable, and it also recommends to use GitHub releases instead.
Replaces #13295.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It might still make sense to use the timeout values from GH-13295.

@Ayesh Ayesh force-pushed the ci-fix-caddy-links branch from 7fbc224 to e99eda3 Compare January 31, 2024 21:59
@Ayesh
Copy link
Member Author

Ayesh commented Jan 31, 2024

Added timeouts, thank you!

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is clearly correct, but I wonder if we should use the gh CLI binary to download the release (https://cli.github.com/manual/gh_release_download), because I'm not 100% sure if unauthenticated access to the release API might be rate-limited.

In any case this change should be applied to the earliest branch that has the setup-caddy action.

@TimWolla
Copy link
Member

Example: gh release -R caddyserver/caddy download --pattern 'caddy_*_linux_amd64.tar.gz'.

@Ayesh Ayesh force-pushed the ci-fix-caddy-links branch from e99eda3 to 2981748 Compare January 31, 2024 22:09
@Ayesh
Copy link
Member Author

Ayesh commented Jan 31, 2024

Definitely makes more sense to use gh in GH actions. I will update the PR after some tinkering.

@Ayesh
Copy link
Member Author

Ayesh commented Jan 31, 2024

I tried with gh with the following:

gh release -R caddyserver/caddy download --pattern 'caddy_*_linux_amd64.tar.gz' -O - | sudo tar -xz -C /usr/bin caddy

In GH Actions, I'm seeing this:

gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable. Example:
  env:
    GH_TOKEN: ${{ github.token }}

I think it'd be more involved to deal with tokens, so I'd say lets go with the direct links for now.

As far as I see from HTTP headers and online, there is no hard limit to those URLs; only api.github.com is rate-limited.

@TimWolla
Copy link
Member

TimWolla commented Jan 31, 2024

I think it'd be more involved to deal with tokens, so I'd say lets go with the direct links for now.

Not really. That github.token is automatically provided by GitHub Actions and valid for a single run only. I thought gh would be able to automatically consume it, but specifying it explicitly is not much more complicated. You should be able to copy that suggested snippet as-is into your workflow file like this:

    - shell: bash
      env:
        GH_TOKEN: ${{ github.token }}
      run: |
        set -x
        gh release -R caddyserver/caddy download --pattern 'caddy_*_linux_amd64.tar.gz' -O - | sudo tar -xz -C /usr/bin caddy
        sudo chmod +x /usr/bin/caddy
        sudo caddy start --config ext/curl/tests/Caddyfile

The caddyserver.com download page is unreliable, and it also recommends to use GitHub releases instead.
@Ayesh Ayesh force-pushed the ci-fix-caddy-links branch from 2981748 to fe791f1 Compare January 31, 2024 22:49
@Ayesh
Copy link
Member Author

Ayesh commented Jan 31, 2024

Ah perfect! I made a quick test and it worked. Submitting said changes for review. TIL, thank you @TimWolla.

@TimWolla TimWolla closed this in 4922b9e Jan 31, 2024
@TimWolla
Copy link
Member

Now merged into PHP-8.1+. This is a clear improvement, thank you!

@Ayesh Ayesh deleted the ci-fix-caddy-links branch February 27, 2024 07:44
@cmb69
Copy link
Member

cmb69 commented Aug 21, 2024

Hmm, did this ever work? Apparently, it fails all the time: https://github.com/php/php-src/actions/runs/10493648028/job/29068097535#step:8:20

The issue had been reported by @Disservin, and I only now had a look.

According to https://stackoverflow.com/questions/68951888/gh-is-not-recognized-error-while-trying-to-create-github-repo-from-command, we would need to install gh first.

@Ayesh
Copy link
Member Author

Ayesh commented Aug 21, 2024

It seems to be not working on LINUX_X64_DEBUG_ZTS_ASAN builds, but works on LINUX_X64_RELEASE_NTS builds.

But yeah you are right, lack of gh seems to be the issue, I believe caused by the difference in runs-on images.

Ayesh added a commit to Ayesh/php-src that referenced this pull request Aug 21, 2024
Related: phpGH-13296.
ASAN builds use a different base image on GitHub Actions, which does not have the `gh` binary installed.
This adds `gh` to the `apt install` list, to make sure it's available on all builds.
Ayesh added a commit to Ayesh/php-src that referenced this pull request Sep 25, 2024
Related: phpGH-13296.
ASAN builds use a different base image on GitHub Actions, which does not have the `gh` binary installed.
This adds `gh` to the `apt install` list, to make sure it's available on all builds.
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

Successfully merging this pull request may close these issues.

4 participants