Skip to content

Commit 1adc7a9

Browse files
Merge branch 'patternfly:main' into main
2 parents a26fe16 + c5cddaf commit 1adc7a9

File tree

18 files changed

+1746
-60
lines changed

18 files changed

+1746
-60
lines changed

.github/upload-preview.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { Octokit } = require('@octokit/rest');
4+
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
5+
const surge = require('surge');
6+
const publishFn = surge().publish();
7+
8+
// From github actions
9+
const ghrepo = process.env.GITHUB_REPOSITORY || '';
10+
11+
const owner = process.env.CIRCLE_PROJECT_USERNAME || ghrepo.split('/')[0]; // patternfly
12+
const repo = process.env.CIRCLE_PROJECT_REPONAME || ghrepo.split('/')[1];
13+
const prnum = process.env.CIRCLE_PR_NUMBER || process.env.GH_PR_NUM;
14+
const prbranch = process.env.CIRCLE_BRANCH || process.env.GITHUB_REF.split('/').pop();
15+
16+
const uploadFolder = process.argv[2];
17+
if (!uploadFolder) {
18+
console.log('Usage: upload-preview uploadFolder');
19+
process.exit(1);
20+
}
21+
22+
const uploadFolderName = path.basename(uploadFolder);
23+
let uploadURL = `${repo}-${prnum ? `pr-component-groups-${prnum}` : prbranch}`.replace(/[\/|\.]/g, '-');
24+
25+
switch(uploadFolderName) {
26+
case 'coverage':
27+
uploadURL += '-a11y.surge.sh';
28+
break;
29+
case 'public':
30+
if (!prnum && prbranch === 'main') {
31+
uploadURL = 'https://pf-extensions.surge.sh/';
32+
}
33+
else {
34+
uploadURL += '.surge.sh';
35+
}
36+
break;
37+
default:
38+
uploadURL += `-${uploadFolderName}`;
39+
uploadURL += '.surge.sh';
40+
break;
41+
}
42+
43+
publishFn({
44+
project: uploadFolder,
45+
p: uploadFolder,
46+
domain: uploadURL,
47+
d: uploadURL,
48+
e: 'https://surge.surge.sh',
49+
endpoint: 'https://surge.surge.sh'
50+
});
51+
52+
function tryAddComment(comment, commentBody) {
53+
if (!commentBody.includes(comment)) {
54+
return comment;
55+
}
56+
return '';
57+
}
58+
59+
if (prnum) {
60+
octokit.issues.listComments({
61+
owner,
62+
repo,
63+
issue_number: prnum
64+
})
65+
.then(res => res.data)
66+
.then(comments => {
67+
let commentBody = '';
68+
const existingComment = comments.find(comment => comment.user.login === 'patternfly-build');
69+
if (existingComment) {
70+
commentBody += existingComment.body.trim();
71+
commentBody += '\n\n';
72+
}
73+
74+
if (uploadFolderName === 'public') {
75+
commentBody += tryAddComment(`Preview: https://${uploadURL}`, commentBody);
76+
}
77+
else if (uploadFolderName === 'coverage') {
78+
commentBody += tryAddComment(`A11y report: https://${uploadURL}`, commentBody);
79+
}
80+
81+
if (existingComment) {
82+
octokit.issues.updateComment({
83+
owner,
84+
repo,
85+
comment_id: existingComment.id,
86+
body: commentBody
87+
}).then(() => console.log('Updated comment!'));
88+
} else {
89+
octokit.issues.createComment({
90+
owner,
91+
repo,
92+
issue_number: prnum,
93+
body: commentBody
94+
}).then(() => console.log('Created comment!'));
95+
}
96+
});
97+
}

.github/workflows/pr-preview.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
### WARNING -- this file was generated by generate-workflows
2+
name: pr-preview
3+
on: pull_request_target
4+
jobs:
5+
build-upload:
6+
runs-on: ubuntu-latest
7+
env:
8+
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
9+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
10+
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
11+
GH_PR_NUM: ${{ github.event.number }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
# Yes, we really want to checkout the PR
15+
- run: |
16+
git fetch origin pull/$GH_PR_NUM/head:tmp
17+
git checkout tmp
18+
19+
- run: |
20+
git rev-parse origin/main
21+
git rev-parse HEAD
22+
git rev-parse origin/main..HEAD
23+
git log origin/main..HEAD --format="%b"
24+
25+
# Yes, we really want to checkout the PR
26+
# Injected by generate-workflows.js
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: '16'
30+
- uses: actions/cache@v2
31+
id: npm-cache
32+
name: Load npm deps from cache
33+
with:
34+
path: '**/node_modules'
35+
key: ${{ runner.os }}-npm-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }}
36+
- run: npm install --frozen-lockfile
37+
if: steps.yarn-cache.outputs.cache-hit != 'true'
38+
- run: npm run build
39+
name: Build component groups
40+
- uses: actions/cache@v2
41+
id: docs-cache
42+
name: Load webpack cache
43+
with:
44+
path: '.cache'
45+
key: ${{ runner.os }}-v4-${{ hashFiles('yarn.lock') }}
46+
- run: npm run build:docs
47+
name: Build docs
48+
- run: node .github/upload-preview.js packages/module/public
49+
name: Upload docs
50+
if: always()
51+
- run: npm run serve:docs & npm run test:a11y
52+
name: a11y tests
53+
- run: node .github/upload-preview.js packages/module/coverage
54+
name: Upload a11y report
55+
if: always()

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ When adding/making changes to a component, always make sure your code is tested:
132132
### Styling:
133133
- for styling always use JSS
134134
- new classNames should be named in camelCase starting with the name of a given component and following with more details clarifying its purpose/component's subsection to which the class is applied (`actionMenu`, `actionMenuDropdown`, `actionMenuDropdownToggle`, etc.)
135+
- do not use `pf-v5-u-XXX` classes, use CSS variables in a custom class instead (styles for the utility classes are not bundled with the standard patternfly.css - it would require the consumer to import also addons.css)
135136

136137
## Building for production
137138

0 commit comments

Comments
 (0)