Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
hbuchel committed Jun 7, 2024
2 parents a3be1a8 + db85581 commit fb60557
Show file tree
Hide file tree
Showing 60 changed files with 731 additions and 478 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@
.github @aws-amplify/documentation-team

#Protected Content
/src/protected @reesscot @srquinn21 @Milan-Shah @swaminator
/src/protected @reesscot @srquinn21 @swaminator
8 changes: 4 additions & 4 deletions .github/workflows/accessibility_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 https://github.com/actions/checkout/commit/9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Setup Node.js 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # 4.0.2 https://github.com/actions/setup-node/releases/tag/v4.0.2
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
- name: Install dependencies
Expand All @@ -23,7 +23,7 @@ jobs:
env:
NODE_OPTIONS: --max_old_space_size=4096
- name: Get changed/new pages to run accessibility tests on
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 https://github.com/actions/github-script/commit/60a0d83039c74a4aee543508d2ffcb1c3799cdea
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: pages-to-a11y-test
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -36,7 +36,7 @@ jobs:
python -m http.server 3000 -d ${{ env.BUILD_DIR }} &
sleep 5
- name: Run accessibility tests on changed/new MDX pages
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 https://github.com/actions/github-script/commit/60a0d83039c74a4aee543508d2ffcb1c3799cdea
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: axeResults
with:
result-encoding: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add_deleted_assets_label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
pull-requests: write # used to add label
steps:
- name: Checkout repository to get the workflow scripts
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Download artifact
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add_redirects_label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
pull-requests: write # used to add label
steps:
- name: Checkout repository to get the workflow scripts
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Download artifact
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_bundle_size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: main
- name: Setup Node.js 20
Expand All @@ -34,7 +34,7 @@ jobs:
const { checkBundleSize } = require('./.github/workflows/scripts/check_bundle_size.js');
return checkBundleSize();
- name: Checkout PR branch
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js 20
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_for_broken_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand All @@ -32,7 +32,7 @@ jobs:
role-to-assume: arn:aws:iam::464149486631:role/github_action_read_slack_webhook_url
aws-region: us-west-2
- name: Read secrets from AWS Secrets Manager into environment variables
uses: aws-actions/aws-secretsmanager-get-secrets@f91b2a3e784edce744f972af1685eca7e24d2302 # v2.0.2
uses: aws-actions/aws-secretsmanager-get-secrets@ff26a0aa6bd4dd5e51326b5afb3f5f6874c958c7 # v2.0.3
with:
secret-ids: |
SLACK_WEBHOOK_URL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_for_console_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_for_deleted_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository to get the workflow scripts
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Get count of deleted files
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: set-deleted-files-count
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_for_new_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Get count of added files
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: set-added-files-count
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_for_new_fragments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Check if there are new fragments
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: new-fragments-boolean
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_for_redirects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository to get the workflow scripts
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Get count of deleted files
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: set-deleted-files-count
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_pr_for_broken_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
# Minimal depth 2 so we can checkout the commit before possible merge commit.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f
with:
category: '/language:${{matrix.language}}'
119 changes: 65 additions & 54 deletions .github/workflows/scripts/check_for_changed_pages.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,74 @@
module.exports = {
getChangedPages: ({ github, context, buildDir }) => {
getChangedPages: async ({ github, context, buildDir }) => {
const fs = require('fs');
const cheerio = require('cheerio');

const urlList = [];

const {
issue: { number: issue_number },
repo: { owner, repo }
} = context;

// Use the Github API to query for the list of files from the PR
return github
.paginate(
'GET /repos/{owner}/{repo}/pulls/{pull_number}/files',
{ owner, repo, pull_number: issue_number },
(response) => response.data.filter((file) => (file.status === 'modified' || file.status === 'added'))
)
.then((files) => {
const possiblePages = [];
const platforms = [
'android',
'angular',
'flutter',
'javascript',
'nextjs',
'react',
'react-native',
'swift',
'vue',
]
files.forEach(({filename}) => {
const isPage = filename.startsWith('src/pages') && (filename.endsWith('index.mdx') || filename.endsWith('index.tsx'));
if(isPage) {

const path = filename.replace('src/pages', '').replace('/index.mdx', '').replace('/index.tsx', '');
if(path.includes('[platform]')) {
platforms.forEach((platform) => {
possiblePages.push(path.replace('[platform]', platform));
})
} else {
possiblePages.push(path);
}
}
});

const siteMap = fs.readFileSync(`${buildDir}/sitemap.xml`);

const siteMapParse = cheerio.load(siteMap, {
xml: true
});

siteMapParse('url').each(function () {
urlList.push(siteMapParse(this).find('loc').text());
});

const pages = possiblePages.filter((page) => urlList.includes(`https://docs.amplify.aws${page}/`));

return pages;
});
},
}
const possiblePages = [];
const platforms = [
'android',
'angular',
'flutter',
'javascript',
'nextjs',
'react',
'react-native',
'swift',
'vue'
];

const changedFiles = await github.paginate(
'GET /repos/{owner}/{repo}/pulls/{pull_number}/files',
{ owner, repo, pull_number: issue_number },
(response) =>
response.data.filter(
(file) => file.status === 'modified' || file.status === 'added'
)
);

// Get only the changed files that are pages and build out the
// possiblePages array
changedFiles.forEach(({ filename }) => {
const isPage =
filename.startsWith('src/pages') &&
(filename.endsWith('index.mdx') || filename.endsWith('index.tsx'));
if (isPage) {
const path = filename
.replace('src/pages', '')
.replace('/index.mdx', '')
.replace('/index.tsx', '');
if (path.includes('[platform]')) {
platforms.forEach((platform) => {
possiblePages.push(path.replace('[platform]', platform));
});
} else {
possiblePages.push(path);
}
}
});

// Get the sitemap and parse for an array of site URLs
const siteMap = fs.readFileSync(`${buildDir}/sitemap.xml`);

const siteMapParse = cheerio.load(siteMap, {
xml: true
});

siteMapParse('url').each(function () {
urlList.push(siteMapParse(this).find('loc').text());
});

// Filter the possiblePages for only those that are part of the sitemap
const pages = possiblePages.filter((page) =>
urlList.includes(`https://docs.amplify.aws${page}/`)
);

return pages;
}
};
2 changes: 1 addition & 1 deletion .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand Down
15 changes: 15 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ Videos can be added using the `<Video />` component and referencing a path to th
<Video src="/path/to/video.mp4" />
```

## Accessibility testing

We run automated accessibility testing on pages affected by a pull request in both light and dark mode. Some common violations and their solutions are listed here:

```
Element has insufficient color contrast
```
[Text colors must have a contrast ratio of 4.5:1 against their background](https://www.w3.org/TR/WCAG22/#contrast-minimum). Avoid adding custom styling to text; our design system should ensure that accessible color combinations are in use.

```
Heading order invalid
```
Headings should be properly nested. This means, for example, an `<h3>` element must be nested beneath an `<h2>` element on the page, an `<h4>` must be nested beneath an `<h3>` and so on. Use [markdown syntax to create your headings](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#headings).


## Debug client-side code with browser developer tools

### Prerequisites
Expand Down
8 changes: 7 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ import rehypeMdxCodeProps from 'rehype-mdx-code-props';
const require = createRequire(import.meta.url);
import rehypeImgSize from 'rehype-img-size';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';

dotenv.config({ path: './.env.custom' });

const nextJSConfig = () => {
const withMDX = createMDX({
extension: /\.mdx$/,
options: {
remarkPlugins: [remarkGfm],
rehypePlugins: [[rehypeImgSize, { dir: 'public' }], rehypeMdxCodeProps]
rehypePlugins: [
[rehypeImgSize, { dir: 'public' }],
rehypeMdxCodeProps,
rehypeSlug
]
}
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"rehype": "^11.0.0",
"rehype-img-size": "^1.0.1",
"rehype-mdx-code-props": "^2.0.0",
"rehype-slug": "^6.0.0",
"remark": "^14.0.2",
"remark-gfm": "^3.0.0",
"remark-mdx": "^2.3.0",
Expand Down Expand Up @@ -94,12 +95,12 @@
"prismjs": "^1.27.0",
"@adobe/css-tools": "4.3.2",
"follow-redirects": "^1.15.6",
"ip": "2.0.1",
"sharp": "0.32.6",
"ejs": "3.1.10"
},
"scripts": {
"clean": "rm -rf node_modules yarn.lock",
"countGen2": "node tasks/count-gen2pages.mjs",
"refresh": "yarn clean && yarn",
"test:unit": "jest --projects jest.unit.config.js --coverage",
"test:e2e": "jest --projects e2e/jest.e2e.config.js",
Expand Down
Loading

0 comments on commit fb60557

Please sign in to comment.