Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 964ae11

Browse files
committed
chore(ci): refactor CI and upgrade actions
Signed-off-by: Jon Koops
1 parent dc69ddb commit 964ae11

File tree

11 files changed

+253
-680
lines changed
  • .github
    • actions/setup-project
      • action.yml
    • upload-preview.js
    • workflows
      • add-new-issues-to-project.yml
      • documentation.yml
      • extensions.yml
      • main.yml
      • pr-preview.yml
      • promote.yml
      • release.yml
      • stale.yml
  • package.json

11 files changed

+253
-680
lines changed

.github/actions/setup-project/action.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Set up and build project
2+
inputs:
3+
skip-build:
4+
description: Skip the build step
5+
required: false
6+
default: 'false'
7+
skip-build-cache:
8+
description: Skip the build cache step
9+
required: false
10+
default: 'false'
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 18
18+
check-latest: true
19+
20+
- name: Get Yarn configuration
21+
id: yarn-config
22+
shell: bash
23+
run: |
24+
echo "cache-directory=$(yarn cache dir)" >> $GITHUB_OUTPUT
25+
26+
# TODO: This can be simplified to use the `cache` option of the `actions/setup-node` action when it supports Corepack.
27+
# See: https://github.com/actions/setup-node/issues/531
28+
- uses: actions/cache@v4
29+
name: Setup Yarn cache
30+
with:
31+
# Also cache Cypress binary.
32+
path: |
33+
~/.cache/Cypress
34+
${{ steps.yarn-config.outputs.cache-directory }}
35+
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('yarn.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-yarn-cache-
38+
39+
- name: Install dependencies
40+
shell: bash
41+
run: yarn install --frozen-lockfile
42+
43+
- uses: actions/cache@v4
44+
if: inputs.skip-build != 'true' && inputs.skip-build-cache != 'true'
45+
id: cache-build
46+
name: Cache build
47+
with:
48+
path: |
49+
packages/*/dist
50+
packages/*/next
51+
packages/*/deprecated
52+
packages/*/components
53+
packages/react-styles/css
54+
packages/react-core/layouts
55+
packages/react-core/helpers
56+
key: ${{ runner.os }}-build-${{ hashFiles('yarn.lock', '**/package.json', 'packages/**', '!**/node_modules', '!**/dist') }}
57+
58+
- name: Run build
59+
if: inputs.skip-build != 'true' && steps.cache-build.outputs.cache-hit != 'true'
60+
shell: bash
61+
run: yarn build && yarn build:umd

.github/upload-preview.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const fs = require('fs');
21
const path = require('path');
32
const { Octokit } = require('@octokit/rest');
43
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
@@ -7,11 +6,9 @@ const publishFn = surge().publish();
76

87
// From github actions
98
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();
9+
const [owner, repo] = ghrepo.split('/');
10+
const prnum = process.env.GH_PR_NUM;
11+
const prbranch = process.env.GITHUB_REF.split('/').pop();
1512

1613
const uploadFolder = process.argv[2];
1714
if (!uploadFolder) {

.github/workflows/add-new-issues-to-project.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
name: Add new issues to PatternFly Issues project
2-
32
on:
43
issues:
54
types:
65
- opened
7-
86
jobs:
97
add-to-project:
108
name: Add issue to project
119
runs-on: ubuntu-latest
1210
steps:
13-
- uses: actions/add-to-project@v0.3.0
11+
- uses: actions/add-to-project@v1.0.1
1412
with:
1513
project-url: https://github.com/orgs/patternfly/projects/7
1614
github-token: ${{ secrets.GH_PROJECTS }}

.github/workflows/documentation.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Documentation
2+
on:
3+
pull_request_target:
4+
workflow_call:
5+
secrets:
6+
SURGE_LOGIN:
7+
required: true
8+
SURGE_TOKEN:
9+
required: true
10+
GH_PR_TOKEN:
11+
required: true
12+
jobs:
13+
deploy:
14+
name: Build, test & deploy
15+
runs-on: ubuntu-latest
16+
env:
17+
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
18+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
19+
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
20+
GH_PR_NUM: ${{ github.event.number }}
21+
steps:
22+
- name: Check out project from PR branch
23+
if: github.event_name == 'pull_request_target'
24+
uses: actions/checkout@v4
25+
with:
26+
# Checkout the merge commit so that we can access the PR's changes.
27+
# This is nessesary because `pull_request_target` checks out the base branch (e.g. `main`) by default.
28+
ref: ${{ github.event.pull_request.merge_commit_sha }}
29+
30+
- name: Check out project
31+
if: github.event_name != 'pull_request_target'
32+
uses: actions/checkout@v4
33+
34+
- name: Set up and build project
35+
uses: ./.github/actions/setup-project
36+
37+
- name: Build documentation
38+
run: yarn build:docs
39+
40+
- name: Upload documentation
41+
if: always()
42+
run: node .github/upload-preview.js packages/react-docs/public
43+
44+
- name: Run accessibility tests
45+
run: yarn serve:docs & yarn test:a11y
46+
47+
- name: Upload accessibility results
48+
if: always()
49+
run: node .github/upload-preview.js packages/react-docs/coverage

.github/workflows/extensions.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name: Add relevant issues to extensions project board
2-
32
on:
43
issues:
54
types:
65
- labeled
7-
86
jobs:
97
add-to-extensions:
108
if: github.event.label.name == 'extension'
119
name: Add issue to extensions board
1210
runs-on: ubuntu-latest
1311
steps:
14-
- uses: actions/add-to-project@v0.3.0
12+
- uses: actions/add-to-project@v1.0.1
1513
with:
1614
project-url: https://github.com/orgs/patternfly/projects/12
1715
github-token: ${{ secrets.GH_PROJECTS }}

.github/workflows/main.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
workflow_call:
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out project
12+
uses: actions/checkout@v4
13+
14+
- name: Set up project
15+
uses: ./.github/actions/setup-project
16+
with:
17+
skip-build: true
18+
19+
- uses: actions/cache@v4
20+
name: Cache files proccesed by ESLint
21+
with:
22+
path: .eslintcache
23+
key: ${{ runner.os }}-eslint-cache
24+
25+
- name: Run linter
26+
run: yarn lint:all
27+
28+
build:
29+
name: Build
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Check out project
33+
uses: actions/checkout@v4
34+
35+
- name: Set up and build project
36+
uses: ./.github/actions/setup-project
37+
38+
unit-tests:
39+
name: Unit tests
40+
runs-on: ubuntu-latest
41+
needs: build
42+
steps:
43+
- name: Check out project
44+
uses: actions/checkout@v4
45+
46+
- name: Set up and build project
47+
uses: ./.github/actions/setup-project
48+
49+
- name: Run tests
50+
run: yarn test --maxWorkers=2
51+
52+
demo-app:
53+
name: Build demo app
54+
runs-on: ubuntu-latest
55+
needs: build
56+
steps:
57+
- name: Check out project
58+
uses: actions/checkout@v4
59+
60+
- name: Set up and build project
61+
uses: ./.github/actions/setup-project
62+
63+
- name: Build demo app
64+
run: yarn build:integration
65+
66+
- name: Upload demo app
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: demo-app
70+
path: packages/react-integration/demo-app-ts/public
71+
72+
integration-tests:
73+
name: Integration tests
74+
runs-on: ubuntu-latest
75+
needs: demo-app
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
worker: [0, 1, 2, 3, 4]
80+
steps:
81+
- name: Check out project
82+
uses: actions/checkout@v4
83+
84+
- name: Set up and build project
85+
uses: ./.github/actions/setup-project
86+
87+
- name: Download demo app
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: demo-app
91+
path: packages/react-integration/demo-app-ts/public
92+
93+
- name: Print environment variables
94+
run: printenv
95+
96+
- name: Run Cypress tests
97+
run: yarn serve:integration & yarn test:integration -s $(node .github/split.js)
98+
env:
99+
WORKER_NUM: ${{ matrix.worker }}
100+
WORKER_COUNT: 5

0 commit comments

Comments
(0)