Skip to content

ci: update caddy job to use GitHub Releases - #13296

Closed
Ayesh wants to merge 1 commit into
php:masterfrom
Ayesh:ci-fix-caddy-links
Closed

ci: update caddy job to use GitHub Releases#13296
Ayesh wants to merge 1 commit into
php:masterfrom
Ayesh:ci-fix-caddy-links

Conversation

@Ayesh

Copy link
Copy Markdown
Member

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

@iluuu1994iluuu1994 left a comment

Copy link
Copy Markdown
Member

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
Ayeshforce-pushed the ci-fix-caddy-links branch from 7fbc224 to e99eda3CompareJanuary 31, 2024 21:59
@Ayesh

Copy link
Copy Markdown
MemberAuthor

Added timeouts, thank you!

@TimWollaTimWolla left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@Ayesh
Ayeshforce-pushed the ci-fix-caddy-links branch from e99eda3 to 2981748CompareJanuary 31, 2024 22:09
@Ayesh

Copy link
Copy Markdown
MemberAuthor

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

@Ayesh

Copy link
Copy Markdown
MemberAuthor

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

TimWolla commented Jan 31, 2024

Copy link
Copy Markdown
Member

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
Ayeshforce-pushed the ci-fix-caddy-links branch from 2981748 to fe791f1CompareJanuary 31, 2024 22:49
@Ayesh

Copy link
Copy Markdown
MemberAuthor

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

@TimWolla

Copy link
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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 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 freeto 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

@Ayesh@TimWolla@cmb69@iluuu1994