Skip to content

Commit 60efffb

Browse files
committed
chore(ci): refactor CI and upgrade actions
Signed-off-by: Jon Koops <[email protected]>
1 parent dc69ddb commit 60efffb

File tree

11 files changed

+253
-679
lines changed

11 files changed

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

0 commit comments

Comments
 (0)