From 6815c9662fe4a1548e124c3659c716aee603885e Mon Sep 17 00:00:00 2001 From: Ashley Date: Mon, 24 Mar 2025 11:16:49 -0400 Subject: [PATCH 1/4] created new tests for api article body (#54885) --- .../api-article-body-test-page.md | 70 +++++++++++++++++ .../get-started/start-your-journey/index.md | 1 + src/fixtures/tests/api-article-body.ts | 77 +++++++++++++++++++ src/shielding/tests/shielding.ts | 8 +- 4 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 src/fixtures/fixtures/content/get-started/start-your-journey/api-article-body-test-page.md create mode 100644 src/fixtures/tests/api-article-body.ts diff --git a/src/fixtures/fixtures/content/get-started/start-your-journey/api-article-body-test-page.md b/src/fixtures/fixtures/content/get-started/start-your-journey/api-article-body-test-page.md new file mode 100644 index 000000000000..ac6678a5da12 --- /dev/null +++ b/src/fixtures/fixtures/content/get-started/start-your-journey/api-article-body-test-page.md @@ -0,0 +1,70 @@ +--- +title: Api Article Body Test Page +shortTitle: About GitHub and Git +intro: 'You can use Github and Git to collaborate on work.' +versions: + fpt: '*' + ghes: '*' + ghec: '*' +type: overview +topics: + - Git + - Fundamentals + - GitHub + - Collaboration + - Community +redirect_from: + - /get-started/quickstart/about-github-and-git +--- + +## About GitHub + +GitHub is a cloud-based platform where you can store, share, and work together with others to write code. + +Storing your code in a "repository" on GitHub allows you to: + +* **Showcase or share** your work. +* **Track and manage** changes to your code over time. +* Let others **review** your code, and make suggestions to improve it. +* **Collaborate** on a shared project, without worrying that your changes will impact the work of your collaborators before you're ready to integrate them. + +Collaborative working, one of GitHub’s fundamental features, is made possible by the open-source software, Git, upon which GitHub is built. + +## About Git + +Git is a version control system that intelligently tracks changes in files. Git is particularly useful when you and a group of people are all making changes to the same files at the same time. + +Typically, to do this in a Git-based workflow, you would: + +* **Create a branch** off from the main copy of files that you (and your collaborators) are working on. +* **Make edits** to the files independently and safely on your own personal branch. +* Let Git intelligently **merge** your specific changes back into the main copy of files, so that your changes don't impact other people's updates. +* Let Git **keep track** of your and other people's changes, so you all stay working on the most up-to-date version of the project. + + + +### How do Git and GitHub work together? + +When you upload files to GitHub , you'll store them in a "Git repository." This means that when you make changes (or "commits") to your files in GitHub, Git will automatically start to track and manage your changes. + +There are plenty of Git-related actions that you can complete on GitHub directly in your browser, such as creating a Git repository, creating branches, and uploading and editing files. + +However, most people work on their files locally (on their own computer), then continually sync these local changes—and all the related Git data—with the central "remote" repository on GitHub. There are plenty of tools that you can use to do this, such as GitHub Desktop. + +Once you start to collaborate with others and all need to work on the same repository at the same time, you’ll continually: + +* **Pull** all the latest changes made by your collaborators from the remote repository on GitHub. +* **Push** back your own changes to the same remote repository on GitHub. + +Git figures out how to intelligently merge this flow of changes, and GitHub helps you manage the flow through features such as "pull requests." + +## Where do I start? + +If you're new to GitHub, and unfamiliar with Git, we recommend working through the articles in the Start Your Journey category. The articles focus on tasks you can complete directly in your browser on GitHub and will help you to: + +* **Create an account** on GitHub. +* **Learn the "GitHub Flow"**, and the key principles of collaborative working (branches, commits, pull requests, merges). +* **Personalise your profile** to share your interests and skills. +* **Explore GitHub** to find inspiration for your own projects and connect with others. +* Learn how to **download** interesting code for your own use. +* Learn how to **upload** something you're working on to a GitHub repository. diff --git a/src/fixtures/fixtures/content/get-started/start-your-journey/index.md b/src/fixtures/fixtures/content/get-started/start-your-journey/index.md index 41350b034a18..edb1fb37c084 100644 --- a/src/fixtures/fixtures/content/get-started/start-your-journey/index.md +++ b/src/fixtures/fixtures/content/get-started/start-your-journey/index.md @@ -9,6 +9,7 @@ children: - /hello-world - /link-rewriting - /dynamic-title + - /api-article-body-test-page redirect_from: - /get-started/quickstart --- diff --git a/src/fixtures/tests/api-article-body.ts b/src/fixtures/tests/api-article-body.ts new file mode 100644 index 000000000000..55f9f16a246e --- /dev/null +++ b/src/fixtures/tests/api-article-body.ts @@ -0,0 +1,77 @@ +import { beforeAll, describe, expect, test } from 'vitest' + +import { get } from '#src/tests/helpers/e2etest.js' + +const makeURL = (pathname: string) => `/api/article/body?${new URLSearchParams({ pathname })}` + +describe('article body api', () => { + beforeAll(() => { + // If you didn't set the `ROOT` variable, the tests will fail rather + // cryptically. So as a warning for engineers running these tests, + // alert in case it was accidentally forgotten. + if (!process.env.ROOT) { + console.warn( + 'WARNING: The articlebody tests require the ROOT environment variable to be set to the fixture root', + ) + } + // Ditto for fixture-based translations to work + if (!process.env.TRANSLATIONS_FIXTURE_ROOT) { + console.warn( + 'WARNING: The articlebody tests require the TRANSLATIONS_FIXTURE_ROOT environment variable to be set', + ) + } + }) + + test('happy path', async () => { + const res = await get(makeURL('/en/get-started/start-your-journey/api-article-body-test-page')) + expect(res.statusCode).toBe(200) + expect(res.headers['content-type']).toContain('text/markdown') + expect(res.body).toContain('## About GitHub') + expect(res.body).toContain('## About Git') + expect(res.body).toMatch(/^#+\s+\w+/m) // Check for any markdown heading pattern + + expect(res.headers['set-cookie']).toBeUndefined() + expect(res.headers['cache-control']).toContain('public') + expect(res.headers['cache-control']).toMatch(/max-age=[1-9]/) + expect(res.headers['surrogate-control']).toContain('public') + expect(res.headers['surrogate-control']).toMatch(/max-age=[1-9]/) + }) + + test('a pathname that does not exist', async () => { + const res = await get(makeURL('/en/never/heard/of')) + expect(res.statusCode).toBe(404) + const { error } = JSON.parse(res.body) + expect(error).toBe("No page found for '/en/never/heard/of'") + }) + + test("no 'pathname' query string at all", async () => { + const res = await get('/api/article/body') + expect(res.statusCode).toBe(400) + const { error } = JSON.parse(res.body) + expect(error).toBe("No 'pathname' query") + }) + + test('has proper markdown structure with frontmatter removed', async () => { + const res = await get(makeURL('/en/get-started/start-your-journey/api-article-body-test-page')) + + expect(res.statusCode).toBe(200) + // Should not contain frontmatter + expect(res.body).not.toMatch(/^---/) + // Should have at least one heading + expect(res.body).toMatch(/^#{1,6}\s+\w+/m) + }) + + test("empty 'pathname' query string", async () => { + const res = await get('/api/article/body?pathname=%20') + expect(res.statusCode).toBe(400) + const { error } = JSON.parse(res.body) + expect(error).toBe("'pathname' query empty") + }) + + test('repeated pathname query string key', async () => { + const res = await get('/api/article/body?pathname=a&pathname=b') + expect(res.statusCode).toBe(400) + const { error } = JSON.parse(res.body) + expect(error).toBe("Multiple 'pathname' keys") + }) +}) diff --git a/src/shielding/tests/shielding.ts b/src/shielding/tests/shielding.ts index 457adcf7ff29..a68bfca4043d 100644 --- a/src/shielding/tests/shielding.ts +++ b/src/shielding/tests/shielding.ts @@ -72,24 +72,24 @@ describe('index.md and .md suffixes', () => { }) // TODO-ARTICLEAPI: unskip tests or replace when ready to ship article API - test.skip('any URL that ends with /.md redirects', async () => { + test('any URL that ends with /.md redirects', async () => { // With language prefix { const res = await get('/en/get-started/hello.md') expect(res.statusCode).toBe(302) - expect(res.headers.location).toBe('/en/get-started/hello') + expect(res.headers.location).toBe('/api/article/body?pathname=/en/get-started/hello') } // Without language prefix { const res = await get('/get-started/hello.md') expect(res.statusCode).toBe(302) - expect(res.headers.location).toBe('/get-started/hello') + expect(res.headers.location).toBe('/api/article/body?pathname=/get-started/hello') } // With query string { const res = await get('/get-started/hello.md?foo=bar') expect(res.statusCode).toBe(302) - expect(res.headers.location).toBe('/get-started/hello?foo=bar') + expect(res.headers.location).toBe('/api/article/body?pathname=/get-started/hello') } }) }) From b1eea689ce8a979d193d6bc473ac6e8fb486b1a3 Mon Sep 17 00:00:00 2001 From: Ben Ahmady <32935794+subatoi@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:47:42 +0000 Subject: [PATCH 2/4] Fix(?) the reusable ready-for-docs-review workflow (#54975) --- .github/workflows/ready-for-doc-review.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ready-for-doc-review.yml b/.github/workflows/ready-for-doc-review.yml index 25c46eb4cf23..a156e21afd95 100644 --- a/.github/workflows/ready-for-doc-review.yml +++ b/.github/workflows/ready-for-doc-review.yml @@ -45,6 +45,7 @@ jobs: # Check if the PR is connected to an issue that has the DIY docs label. The grep command parses through the PR description to find issue numbers that are linked in the PR description. The GitHub CLI command then checks if the issue exists in the docs-content repo, then checks if the linked docs-content issues have the DIY docs label. If the linked issues have the DIY docs label, the DIY_DOCS_LABEL environment variable is set to true. - name: Check if PR is connected to DIY docs issue + if: github.repository == 'github/docs-internal' id: check-diy-docs env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} @@ -74,7 +75,7 @@ jobs: # If the PR description contains a link to a DIY docs issue, add the DIY docs label to the PR. - name: Add the DIY docs label if connected to a DIY docs issue - if: ${{ env.DIY_DOCS_LABEL == 'true' }} + if: ${{ env.DIY_DOCS_LABEL == 'true' }} && github.repository == 'github/docs-internal' env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PR_URL: ${{ github.event.pull_request.html_url }} From 153d57fbebd0ac780007159d8271a65a5ffa51a7 Mon Sep 17 00:00:00 2001 From: Patrick Knight Date: Mon, 24 Mar 2025 12:06:43 -0500 Subject: [PATCH 3/4] GA - Enterprise rulesets and custom properties (#54726) Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com> --- .../enforcing-policies-for-code-governance.md | 2 -- ...ing-custom-properties-for-repositories-in-your-enterprise.md | 2 -- 2 files changed, 4 deletions(-) diff --git a/content/admin/enforcing-policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-code-governance.md b/content/admin/enforcing-policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-code-governance.md index 5c7a9d0bf0c2..11a1490c5cea 100644 --- a/content/admin/enforcing-policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-code-governance.md +++ b/content/admin/enforcing-policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-code-governance.md @@ -16,8 +16,6 @@ topics: ## Introduction ->[!NOTE] Enterprise code rulesets are currently in public preview and subject to change. - You can create rulesets to control how users can interact with code in repositories across your enterprise. You can: * Create a **branch or tag ruleset** to control things like who can push commits to a certain branch, how commits must be formatted, or who can delete or rename a tag. diff --git a/content/admin/managing-accounts-and-repositories/managing-repositories-in-your-enterprise/managing-custom-properties-for-repositories-in-your-enterprise.md b/content/admin/managing-accounts-and-repositories/managing-repositories-in-your-enterprise/managing-custom-properties-for-repositories-in-your-enterprise.md index 10cc2a1975a9..8777024b5993 100644 --- a/content/admin/managing-accounts-and-repositories/managing-repositories-in-your-enterprise/managing-custom-properties-for-repositories-in-your-enterprise.md +++ b/content/admin/managing-accounts-and-repositories/managing-repositories-in-your-enterprise/managing-custom-properties-for-repositories-in-your-enterprise.md @@ -9,8 +9,6 @@ topics: shortTitle: Custom properties --- -> [!NOTE] Custom properties for your enterprise are in {% data variables.release-phases.public_preview %} and subject to change. - Custom properties allow you to decorate your repositories with information such as compliance frameworks, data sensitivity, or project details. Custom properties are private and can only be viewed by people with read permissions to the repository. An enterprise can have up to 100 property definitions. An allowed value list can have up to 200 items. Defining custom properties at the enterprise level allows you to create consistent values that users can apply to repositories. With custom properties in place, you can apply consistent governance across repositories in your enterprise by creating a ruleset or repository policy targeting repositories with certain properties. See [AUTOTITLE](/admin/managing-accounts-and-repositories/managing-repositories-in-your-enterprise/governing-how-people-use-repositories-in-your-enterprise). From 37e2b385273e520ea3de38ba01a1c16de1ad8028 Mon Sep 17 00:00:00 2001 From: Sophie <29382425+sophietheking@users.noreply.github.com> Date: Mon, 24 Mar 2025 18:09:19 +0100 Subject: [PATCH 4/4] Merge method rule [GA] (#54698) Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com> --- .../managing-rulesets/available-rules-for-rulesets.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md b/content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md index 796bc86dd9ed..cc9bb852ea95 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md @@ -131,10 +131,7 @@ For complex pull requests that require many reviews, requiring an approval from Optionally, you can require all comments on the pull request to be resolved before it can be merged to a branch. This ensures that all comments are addressed or acknowledged before merge. {% ifversion repo-rules-merge-type %} -> [!NOTE] -> Allowed merge method is currently in public preview, the rule is currently non-bypassable, and subject to change. - -Optionally, you can require a merge type of merge, squash or rebase. This means the targeted branches may only be merged based on the allowed type. Additionally if the repository has disabled a merge method and the ruleset required a different method, the merge will be blocked. For more information, see [AUTOTITLE](/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github). +Optionally, you can require a merge type of merge, squash, or rebase. This means the targeted branches may only be merged based on the allowed type. Additionally if the repository has disabled a merge method and the ruleset required a different method, the merge will be blocked. See [AUTOTITLE](/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github). {% endif %} ## Require status checks to pass before merging