Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/nested-cert-nav' into nested-nav…
Browse files Browse the repository at this point in the history
…---reporting
  • Loading branch information
stevector committed Oct 7, 2024
2 parents 4d23c39 + d0959e4 commit efedf9c
Show file tree
Hide file tree
Showing 122 changed files with 2,286 additions and 710 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: JavaScript Unit Tests
on:
pull_request:
paths:
- 'src/**'
- '.github/workflows/vitest.yml'
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'latest'
- run: npm ci
- run: npx vitest src/components
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,35 @@ Alternatively, if you'd rather create a classic-style token:
GITHUB_API=$TOKENHASH
```
## Using GitHub Codespaces
A [GitHub Codespace](https://github.com/features/codespaces) can be used to test the site as well. To set up a Codespace, navigate to the branch you want to use as the base (e.g. `main`) and click the Code dropdown.
![Codespaces screenshot](/source/images/assets/codespaces-setup.png)
This will take you to a VSCode-like interface with a Terminal window. From here, export your GitHub API token you created in the previous step using the following command (replacing `$TOKENHASH` with your API token):
```bash{promptUser: user}
export GITHUB_API=$TOKENHASH
```
Now you can run `npm ci` and `npm start` in the Terminal panel at the bottom of the page. The docs site will build inside the Codespaces container and install Node dependencies just like it would on your local machine. When the Node server is running, a dialog box will appear at the bottom right corner asking if you want to open the Codespace in a browser and if you want to make the Codespace public.
![Codespaces open in browser](/source/images/assets/codespaces-application-available.png)
Clicking on the link will take you to a live site that's running on the current branch of the repository. If you opted to make the Codespace public, you can share the link to others and they will be able to view the site after accepting a warning that they are visiting someone else's Codespace. If the Codespace was not made public, only your GitHub user will be able to see it.
### Working with branches on Codespaces
You can open a Codespace (or load an existing Codespace) on a particular branch by first navigating to that branch in the GitHub repository. Alternately, if you already have the VSCode editor open, you can select a specific branch by clicking the branch name at the bottom left, then selecting the branch you would like to switch to in the panel that appears at the top of the screen. The Codespace will make the necessary adjustments and rebuild the docs site on that branch.
![Codespaces branch](/source/images/assets/codespaces-branch.png)
![Codespaces branch selection](/source/images/assets/codespaces-branch-list.png)
### Notes on running in Codespaces
Codespaces is free for individuals for [60 hours of runtime for 2 cores](https://github.com/features/codespaces#pricing), after which your _user_ is billed for additional time. It's unclear whether Pantheon's Enterprise account would own billing, but as of this writing it appears to be billed on a per user basis. For this reason, it's important to _not leave your Codespaces running_ when you're done with them.
## Install With The Gatsby Cli
From the `documentation` directory:
Expand Down Expand Up @@ -112,8 +141,19 @@ You can view the local environment at `localhost:8000/`. Updates to docs are aut
## Testing
We include several tools to test that new content doesn't break the documentation. Most of these tests are performed automatically by our continuous integration service, but pull requests created from external contributors aren't included in CI tests. If you want to manually test your branch, you can execute the following tests within the Docker container.
To reduced the likelihood of regressions and bugs this site uses a few different testing tools:
### Visual Regression Tests
### Merge Conflicts
Within the [`tests`](/tests/) directory there are a number of visual regression tests that can be run to compare the current state of the site to a PR preview or the live site.
These tests are meant to be run locally instead of CI as they have a high rate of false positives.
### Unit Tests
Unit tests for custom logic are written in in Vitest and can be executed with
```bash
npx vitest src/components
```
To check for merge conflict messages accidentally committed into the docs, run `merge_conflicts.sh` from `scripts`.
These tests are executed in CI via a [GitHub Action](.github/workflows/vitest.yml).
24 changes: 23 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,33 @@ module.exports = {
serialize: ({ query: { site, allMdx } }) => {
return allMdx.edges.map(edge => {
const url = new URL(edge.node.fields.slug, site.siteMetadata.siteUrl).toString();
// Simple hash function to turn a string into a numeric value
// https://chatgpt.com/share/69aeb001-e00f-41b9-98a4-816aa6a0330d
function hashCode(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash |= 0; // Convert to 32bit integer
}
return Math.abs(hash);
}

// Generate time based on title hash
function getSeededTime(title) {
const hash = hashCode(title);

const hours = (hash % 24).toString().padStart(2, '0');
const minutes = (hash % 60).toString().padStart(2, '0');
const seconds = ((hash >> 8) % 60).toString().padStart(2, '0'); // Shift for more variance

return `${hours}:${minutes}:${seconds}`;
}

return {
title: edge.node.frontmatter.title,
description: edge.node.excerpt,
date: edge.node.frontmatter.published_date,
date: `${edge.node.frontmatter.published_date}T${getSeededTime(edge.node.frontmatter.title)}Z`,
url: url,
guid: edge.node.id,
};
Expand Down
18 changes: 18 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,24 @@ exports.createPages = ({ graphql, actions }) => {
component: path.resolve("./src/templates/releaseNotesListing/index.js"),
})

// Create release notes pages for pagination.
const releaseNotesPostsPerPage = 8
const releaseNotesNumPages = Math.ceil(result.data.allReleaseNotes.edges.length / releaseNotesPostsPerPage)

Array.from({ length: releaseNotesNumPages }).forEach((_, i) => {
const path2 = `/release-notes/${i+1}/`;
createPage({
path: path2,
component: path.resolve("./src/templates/releaseNotesListing/index.js"),
context: {
limit: releaseNotesPostsPerPage,
skip: i * releaseNotesPostsPerPage,
numPages: releaseNotesNumPages,
i,
},
})
})

// terminusCommands.forEach(command => {
// const slugRegExp = /:/g
// const slug = command.name.replace(slugRegExp, "-")
Expand Down
70 changes: 46 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 6 additions & 17 deletions source/content/addons/object-cache/howto/wordpress.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ title: Enable Object Cache Pro for WordPress
description: How to install and configure Object Cache Pro for WordPress.
permalink: docs/object-cache/wordpress
tags: [cache, plugins, modules, database]
reviewed: "2023-08-17"
reviewed: "2024-08-08"
contenttype: [doc]
innav: [true]
categories: [cache]
cms: [wordpress]
audience: [development]
product: [--]
integration: [--]
contributors: [jazzsequence]
contributors: [jazzsequence, jkudish]
showtoc: true
---

Expand Down Expand Up @@ -71,11 +71,11 @@ terminus redis:enable <site>

<Alert title="Note" type="info">

If the workflow text in the dashboard turns red, it did not succeed. Please [create a ticket with support](/guides/support/contact-support/#ticket-support) to debug this further.
If the workflow text in the dashboard turns red, it did not succeed. Please [create a ticket with support](/guides/support/contact-support/#general-support-ticket) to debug this further.

</Alert>

1. Once complete, activate the Object Cache Pro plugin from the WordPress Admin or via WP-CLI through Terminus.
1. Once complete, activate the Object Cache Pro plugin from the WordPress Admin or via WP-CLI through Terminus on your development or multidev environment. NOTE: This workflow cannot be run on test or live environments.

**WordPress Admin:**

Expand Down Expand Up @@ -152,25 +152,13 @@ Refer to the [official Object Cache Pro documentation](https://objectcache.pro/d
git add auth.json && git commit -m "Add Object Cache Pro auth token."
```

1. Add the Object Cache Pro repository to your `composer.json` file's `repositories` section. Your final `repositories` section should look something like this:
1. Add the Object Cache Pro repository to your `composer.json` file's `repositories` section.
```json
repositories: [
{
"type": "composer",
"url": "https://objectcache.pro/repo/"
},
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
},
{
"type": "path",
"url": "upstream-configuration"
}
],
```
Expand Down Expand Up @@ -315,6 +303,7 @@ Refer to the [official Object Cache Pro documentation](https://objectcache.pro/d
1. Merge code
1. Activate OCP
1. Flush Redis cache
- The `object-cache.php` drop-in file must be created in your development or multidev environment and committed or pushed to live to work.
- When installed as a `mu-plugin` on a WordPress Multisite, Object Cache Pro handles each subsite separately. The dashboard widget applies to the current site and none of the other sites on the network.
- Flushing the network cache from the network admin will flush all caches across the network.
- Subsites do not get their own configuration or graphs.
Expand Down
8 changes: 4 additions & 4 deletions source/content/cache-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ $regex_json_path_patterns = array(
foreach ($regex_json_path_patterns as $regex_json_path_pattern) {
if (preg_match($regex_json_path_pattern, $_SERVER['REQUEST_URI'])) {
// re-use the rest_post_dispatch filter in the Pantheon page cache plugin
add_filter( 'rest_post_dispatch', 'filter_rest_post_dispatch_send_cache_control', 12, 2 );
add_filter( 'rest_post_dispatch', 'filter_rest_post_dispatch_send_cache_control', 12 );
break;
}
}

// Re-define the send_header value with any custom Cache-Control header
function filter_rest_post_dispatch_send_cache_control( $response, $server ) {
$server->send_header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
function filter_rest_post_dispatch_send_cache_control( $response ) {
$response->header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
return $response;
}
```
Expand All @@ -138,7 +138,7 @@ As an alternative to using HTTP headers to control downstream caching, you can s

<Alert title="Warning" type="danger">

Pantheon does not support manually editing and updating the VCL on Global CDN. We use a standard VCL for all sites on the platform. Requests are accepted, but we do not guarantee change requests will be implemented. To submit a request for [Global CDN](/guides/global-cdn), open a [Support Ticket](/guides/support/contact-support/#ticket-support).
Pantheon does not support manually editing and updating the VCL on Global CDN. We use a standard VCL for all sites on the platform. Requests are accepted, but we do not guarantee change requests will be implemented. To submit a request for [Global CDN](/guides/global-cdn), open a [Support Ticket](/guides/support/contact-support/#general-support-ticket).

Note some customizations to VCL are available via [Advanced Global CDN](/guides/professional-services/advanced-global-cdn). For more information, [Contact Sales](https://pantheon.io/contact-us).

Expand Down
Loading

0 comments on commit efedf9c

Please sign in to comment.