Make CI workflow fork-friendly (skip GHCR login and Codecov on forks)#5661
Conversation
|
This was the CI result in our fork: https://github.com/qultoltd/dspace-angular/actions/runs/25857222186 |
|
I haven't changed any source code and test related code, but 1 test is failed: The problem is here:
|
|
I triggered a CI rerun using an empty commit, now the 20.x tests are succeeding. |
tdonohue
left a comment
There was a problem hiding this comment.
👍 Thanks @kanasznagyzoltan ! This all looks good to me. Merging immediately & porting to all active maintenance branches.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-7_x
git worktree add -d .worktree/backport-5661-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-5661-to-dspace-7_x
git switch --create backport-5661-to-dspace-7_x
git cherry-pick -x c055a095349180ab921f9ad53e5bfe7a70208605 d86c1d11b19fabdc49a14b88624cc616fc43921f 61a9cacfb70e87d51539d329f9e1b0290e1cbc88 b9fe33c06415d1e0f957b83f2d4c10f1e8c07066 |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-8_x
git worktree add -d .worktree/backport-5661-to-dspace-8_x origin/dspace-8_x
cd .worktree/backport-5661-to-dspace-8_x
git switch --create backport-5661-to-dspace-8_x
git cherry-pick -x c055a095349180ab921f9ad53e5bfe7a70208605 d86c1d11b19fabdc49a14b88624cc616fc43921f 61a9cacfb70e87d51539d329f9e1b0290e1cbc88 b9fe33c06415d1e0f957b83f2d4c10f1e8c07066 |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-9_x
git worktree add -d .worktree/backport-5661-to-dspace-9_x origin/dspace-9_x
cd .worktree/backport-5661-to-dspace-9_x
git switch --create backport-5661-to-dspace-9_x
git cherry-pick -x c055a095349180ab921f9ad53e5bfe7a70208605 d86c1d11b19fabdc49a14b88624cc616fc43921f 61a9cacfb70e87d51539d329f9e1b0290e1cbc88 b9fe33c06415d1e0f957b83f2d4c10f1e8c07066 |
|
Manual port to 9.x: #5662 |
|
Manual ported also to 8.x and 7.x. (Realized that the automated ports don't work as well with these GitHub action scripts) |
References
Description
Make the
BuildGitHub Actions workflow fork-friendly: forks can now run the full CI (including e2e tests) without access to upstream-only secrets (GITHUB_TOKENscoped todspace/*packages,CODECOV_TOKEN).Instructions for Reviewers
Today, .github/workflows/build.yml always sets
DOCKER_REGISTRY=ghcr.io, always runsdocker/login-action, and always runs thecodecovjob. On forks this leads to two hard failures:Start DSpace REST Backend via Dockerfails withunauthorizedwhen pullingghcr.io/dspace/dspace-solr,ghcr.io/dspace/dspace,ghcr.io/dspace/dspace-postgres-loadsql— a fork'sGITHUB_TOKENcannot read packages from thedspaceorg.codecovjob fails withToken required because branch is protectedbecause forks do not have theCODECOV_TOKENsecret.This PR scopes those upstream-only operations to the upstream repository only, while preserving current behavior for
dspace/dspace-angular.List of changes in this PR
DOCKER_REGISTRYis now conditional:ghcr.ioondspace/dspace-angular(unchanged behavior, avoids Docker Hub rate limits),docker.ioon forks (where the samedspace/dspace-solr,dspace/dspace,dspace/dspace-postgres-loadsqlimages are publicly pullable without authentication).Login to ${{ env.DOCKER_REGISTRY }}step is guarded byif: github.repository == 'dspace/dspace-angular'. On forks the login is skipped because the fallback registry (docker.io) does not require authentication for these images, and forks cannot authenticate againstghcr.io/dspace/*with their ownGITHUB_TOKENanyway.codecovjob is guarded byif: github.repository == 'dspace/dspace-angular'. Forks do not haveCODECOV_TOKENand have no Codecov project to upload to, so running the job on forks produces only noise.No changes to test logic, dependencies, build steps, or upstream behavior.
How to test / review
On the upstream repo (no behavior change expected):
DOCKER_REGISTRY=ghcr.io, GHCR login executes,codecovjob runs and uploads coverage. The three newif:conditions all evaluate totruebecausegithub.repository == 'dspace/dspace-angular'.On a fork (the fix):
DOCKER_REGISTRYresolves todocker.io.docker compose -f ./docker/docker-compose-ci.yml up -dsuccessfully pullsdocker.io/dspace/dspace-solr:latest,docker.io/dspace/dspace:latest-test,docker.io/dspace/dspace-postgres-loadsql:latestanonymously.codecovjob is skipped on forks (visible as a skipped job).Verified against a fork (
qultoltd/dspace-angular): both the Node 20.x and Node 22.x matrix jobs now go fully green end-to-end, including the e2e/Cypress and SSR verification steps, where they previously failed at the Docker pull step.Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.