Skip to content

Commit

Permalink
chore(ci): refactor CI and upgrade actions
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Koops <[email protected]>
  • Loading branch information
jonkoops committed Apr 23, 2024
1 parent 9fa6654 commit d006998
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 674 deletions.
61 changes: 61 additions & 0 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Set up and build project
inputs:
skip-build:
description: Skip the build step
required: false
default: 'false'
skip-build-cache:
description: Skip the build cache step
required: false
default: 'false'
runs:
using: composite
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
check-latest: true

- name: Get Yarn configuration
id: yarn-config
shell: bash
run: |
echo "cache-directory=$(yarn cache dir)" >> $GITHUB_OUTPUT
# TODO: This can be simplified to use the `cache` option of the `actions/setup-node` action when it supports Corepack.
# See: https://github.com/actions/setup-node/issues/531
- uses: actions/cache@v4
name: Setup Yarn cache
with:
# Also cache Cypress binary.
path: |
~/.cache/Cypress
${{ steps.yarn-config.outputs.cache-directory }}
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-cache-
- name: Install dependencies
shell: bash
run: yarn install --frozen-lockfile

- uses: actions/cache@v4
if: inputs.skip-build != 'true' && inputs.skip-build-cache != 'true'
id: cache-build
name: Cache build
with:
path: |
packages/*/dist
packages/*/next
packages/*/deprecated
packages/*/components
packages/react-styles/css
packages/react-core/layouts
packages/react-core/helpers
key: ${{ runner.os }}-build-${{ hashFiles('yarn.lock', '**/package.json', 'packages/**', '!**/node_modules', '!**/dist') }}

- name: Run build
if: inputs.skip-build != 'true' && steps.cache-build.outputs.cache-hit != 'true'
shell: bash
run: yarn build && yarn build:umd
4 changes: 1 addition & 3 deletions .github/workflows/add-new-issues-to-project.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: Add new issues to PatternFly Issues project

on:
issues:
types:
- opened

jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.3.0
- uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/patternfly/projects/7
github-token: ${{ secrets.GH_PROJECTS }}
49 changes: 49 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Documentation
on:
pull_request_target:
workflow_call:
secrets:
SURGE_LOGIN:
required: true
SURGE_TOKEN:
required: true
GH_PR_TOKEN:
required: true
jobs:
deploy:
name: Build, test & deploy
runs-on: ubuntu-latest
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
GH_PR_NUM: ${{ github.event.number }}
steps:
- name: Check out project from PR branch
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
# Checkout the merge commit so that we can access the PR's changes.
# This is nessesary because `pull_request_target` checks out the base branch (e.g. `main`) by default.
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Check out project
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v4

- name: Set up and build project
uses: ./.github/actions/setup-project

- name: Build documentation
run: yarn build:docs

- name: Upload documentation
if: always()
run: node .github/upload-preview.js packages/react-docs/public

- name: Run accessibility tests
run: yarn serve:docs & yarn test:a11y

- name: Upload accessibility results
if: always()
run: node .github/upload-preview.js packages/react-docs/coverage
4 changes: 1 addition & 3 deletions .github/workflows/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Add relevant issues to extensions project board

on:
issues:
types:
- labeled

jobs:
add-to-extensions:
if: github.event.label.name == 'extension'
name: Add issue to extensions board
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.3.0
- uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/patternfly/projects/12
github-token: ${{ secrets.GH_PROJECTS }}
100 changes: 100 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: CI
on:
push:
pull_request:
workflow_call:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out project
uses: actions/checkout@v4

- name: Set up project
uses: ./.github/actions/setup-project
with:
skip-build: true

- uses: actions/cache@v4
name: Cache files proccesed by ESLint
with:
path: .eslintcache
key: ${{ runner.os }}-eslint-cache

- name: Run linter
run: yarn lint:all

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out project
uses: actions/checkout@v4

- name: Set up and build project
uses: ./.github/actions/setup-project

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out project
uses: actions/checkout@v4

- name: Set up and build project
uses: ./.github/actions/setup-project

- name: Run tests
run: yarn test --maxWorkers=2

demo-app:
name: Build demo app
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out project
uses: actions/checkout@v4

- name: Set up and build project
uses: ./.github/actions/setup-project

- name: Build demo app
run: yarn build:integration

- name: Upload demo app
uses: actions/upload-artifact@v4
with:
name: demo-app
path: packages/react-integration/demo-app-ts/public

integration-tests:
name: Integration tests
runs-on: ubuntu-latest
needs: demo-app
strategy:
fail-fast: false
matrix:
worker: [0, 1, 2, 3, 4]
steps:
- name: Check out project
uses: actions/checkout@v4

- name: Set up and build project
uses: ./.github/actions/setup-project

- name: Download demo app
uses: actions/download-artifact@v4
with:
name: demo-app
path: packages/react-integration/demo-app-ts/public

- name: Print environment variables
run: printenv

- name: Run Cypress tests
run: yarn serve:integration & yarn test:integration -s $(node .github/split.js)
env:
WORKER_NUM: ${{ matrix.worker }}
WORKER_COUNT: 5
Loading

0 comments on commit d006998

Please sign in to comment.