Skip to content
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

ci/contrib: do not fail on missing gh-pages #12834

Merged
merged 1 commit into from
Oct 17, 2023
Merged

Conversation

dvdhrm
Copy link
Contributor

@dvdhrm dvdhrm commented Oct 17, 2023

The current contrib deploy-hook fails if there is no gh-pages branch. Change the CI order to disregard the old gh-pages branch first.

The contrib deploy-hook always creates a fresh gh-pages commit and pushes it out. However, currently it relies on the old gh-pages branch to exist, since it does not ignore errors when pruning it. Fortunately, the code always creates a new orphan branch, since it does not want to keep history for deployments. Therefore, we can simply use:

`git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named <branch>, and override an existing branch if it exists (see -b vs -B). Hence, there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly specify the remote to push to. We no longer set up branch tracking.

Note that running github-actions in a private fork is quite useful to avoid constantly pushing changes to a PR and triggering notifications. Unfortunately, private forks on github do not automatically clone the gh-pages branch. This PR fixes annoying CI failures when updating the master branch on private forks, since github does not automatically clone the gh-pages branch.

The current contrib deploy-hook fails if there is no `gh-pages` branch.
Change the CI order to disregard the old `gh-pages` branch first.

The `contrib` deploy-hook always creates a fresh `gh-pages` commit and
pushes it out. However, currently it relies on the old `gh-pages` branch
to exist, since it does not ignore errors when pruning it. Fortunately,
the code always creates a new orphan branch, since it does not want to
keep history for deployments. Therefore, we can simply use:

    `git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named `<branch>`, and
override an existing branch if it exists (see `-b` vs `-B`). Hence,
there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly
specify the remote to push to. We no longer set up branch tracking.
@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2023

r? @weihanglo

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2023
.github/workflows/contrib.yml Show resolved Hide resolved
@@ -25,14 +25,12 @@ jobs:
run: |
cd src/doc/contrib
mdbook build
git worktree add gh-pages gh-pages
# Override previous ref to avoid keeping history.
git worktree add --orphan -B gh-pages gh-pages
Copy link
Member

Choose a reason for hiding this comment

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

Could you verify that gh-pages doesn't exist in this environment? I did a rudimentary test and got this error:

$ git worktree add --orphan -B gh-pages gh-pages
Preparing worktree (resetting branch 'gh-pages'; was at 8eb8acb)
fatal: a branch named 'gh-pages' already exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-B (rather than -b) explicitly overrides existing branches. I tested this on github-actions on my private fork and it correctly overrides existing branches. Did you get this result on a local test or on github-actions?

Copy link
Member

Choose a reason for hiding this comment

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

-B (rather than -b) explicitly overrides existing branches.

Yeah that's what I supposed. However, it didn't behave that way if my local repo has an existing gh-pages.

I'll merge this as is and see if it works. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. If you have a local branch, it fails. I guess the reason it worked in the workflow is because the gh-pages branch is not synced, so only exists as origin/gh-pages.

This might be a bug in git where --orphan and -B don't work together.

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 17, 2023

📌 Commit 1d26183 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2023
@bors
Copy link
Collaborator

bors commented Oct 17, 2023

⌛ Testing commit 1d26183 with merge 8537dff...

@bors
Copy link
Collaborator

bors commented Oct 17, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 8537dff to master...

@bors bors merged commit 8537dff into rust-lang:master Oct 17, 2023
20 checks passed
@dvdhrm
Copy link
Contributor Author

dvdhrm commented Oct 17, 2023

The post-merge workflow ran successfully:

https://github.com/rust-lang/cargo/actions/runs/6549199896

@weihanglo
Copy link
Member

weihanglo commented Oct 18, 2023

It doesn't work https://doc.crates.io/contrib/.

@dvdhrm could you help fix or revert it?

@weihanglo
Copy link
Member

Ok it does need an old gh-pages to continue. Until we find a better solution I'll revert this for now.

bors added a commit that referenced this pull request Oct 18, 2023
docs(contrib): generate redirection HTML pages in CI

### What does this PR try to resolve?

#12834 wiped out the old content of all link redirections. From my understanding it relies on the existing gh-pages hosting those files.

This PR pulls out the [`generate.py`](https://github.com/rust-lang/cargo/blob/cff41259837c912b44f2eba98777d71996740fe0/generate.py) from older `gh-pages` branch, and run it during the CI deploy job.

### How to review

It succeeds on my fork <https://github.com/weihanglo/cargo/tree/gh-pages> ([CI log](https://github.com/weihanglo/cargo/actions/runs/6564128361/job/17829881499#step:4:1)).

I don't think `.lock` or [`.nojekyll`](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/) is needed. If it causes problem, we can add them back.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 21, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 23, 2023
Update cargo

22 commits in 8eb8acbb116e7923ea2ce33a50109933ed5ab375..d2f6a048529eb8e9ebc55d793abd63456c98fac2
2023-10-17 11:55:04 +0000 to 2023-10-20 18:25:30 +0000
- chore(deps): bump rustix from 0.38.18 to 0.38.19 (rust-lang/cargo#12851)
- refactor: centralize logic of getting max resolve version (rust-lang/cargo#12860)
- If there's a version in the lock file only use that exact version (rust-lang/cargo#12772)
- Make the precise field of a source an Enum (rust-lang/cargo#12849)
- fix(cli): Provide next steps for bad -Z flag (rust-lang/cargo#12857)
- fix(remove): Preserve feature comments (rust-lang/cargo#12837)
- docs: fix typo (rust-lang/cargo#12844)
- chore(triagebot): auto label when PR review state changes (rust-lang/cargo#12856)
- fix(add): Preserve more comments (rust-lang/cargo#12838)
- ci: big ⚠️ to ensure the CNAME file is always there (rust-lang/cargo#12853)
- docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses (rust-lang/cargo#12850)
- docs(contrib): generate redirection HTML pages in CI (rust-lang/cargo#12846)
- docs: remove review capacity notice (rust-lang/cargo#12842)
- fix(help):Clarify install's positional (rust-lang/cargo#12841)
- Adjust `-Zcheck-cfg` for new rustc syntax and behavior (rust-lang/cargo#12845)
- fix(replace): Partial-version spec support (rust-lang/cargo#12806)
- Print environment variables for build script executions with `-vv` (rust-lang/cargo#12829)
- fix(cli): Suggest cargo-search on bad commands (rust-lang/cargo#12840)
- docs(contrib): Policy on manifest editing (rust-lang/cargo#12836)
- ci/contrib: use separate concurrency group (rust-lang/cargo#12835)
- ci/contrib: do not fail on missing gh-pages (rust-lang/cargo#12834)
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)

r? ghost
@ehuss ehuss added this to the 1.75.0 milestone Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants