Skip to content

Commit

Permalink
ci: improve CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime committed Dec 21, 2023
1 parent a5e41c7 commit d162cc9
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 105 deletions.
38 changes: 28 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ updates:
schedule:
interval: weekly
day: friday
groups:
laminas:
patterns:
- "laminas/*"
phpunit:
patterns:
- "phpunit/*"
- "spatie/phpunit-snapshot-assertions"
dev-dependencies:
dependency-type: development

- package-ecosystem: composer
open-pull-requests-limit: 20
versioning-strategy: widen
directory: "/tools"
schedule:
interval: weekly
day: friday
groups:
tools-dependencies:
patterns:
- "*"

- package-ecosystem: npm
open-pull-requests-limit: 20
versioning-strategy: widen
Expand All @@ -18,27 +41,22 @@ updates:
docusaurus:
patterns:
- "@docusaurus/*"
- "@tsconfig/docusaurus"
react:
patterns:
- react
- react-*
- "@types/react"
- "@types/react-*"
dev-dependencies:
dependency-type: development

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: friday
groups:
laminas:
github-actions-dependencies:
patterns:
- "laminas/*"
phpstan:
patterns:
- "phpstan/*"
- "slam/phpstan-laminas-framework"
phpunit:
patterns:
- "phpunit/*"
- "spatie/phpunit-snapshot-assertions"
- "*"
89 changes: 89 additions & 0 deletions .github/workflows/__build-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
workflow_call:
inputs:
publish:
default: false
type: boolean

jobs:
generate-documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: ⚙️ Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: none, curl, json, dom, tokenizer, xml, xmlwriter, simplexml, iconv, mbstring, intl, sodium

- name: ♻️ Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: ♻️ Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: ⚙️ Install dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer --working-dir=tools install --no-progress --prefer-dist --optimize-autoloader
- name: ♻️ Tools cache
uses: actions/cache@v3
with:
path: tools/cache
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
- name: 📃 Generate documentation
run: composer generate-docs

- name: 📦 Upload generated documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: website/docs

build-website:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: documentation

- uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
cache-dependency-path: website/yarn.lock

- name: ⚙️ Install Dependencies
working-directory: website
run: yarn install --frozen-lockfile

- name: ♻️ Webpack cache
uses: actions/cache@v3
with:
path: website/node_modules/.cache/webpack
key: ${{ runner.os }}-webpack-${{ github.sha }}
restore-keys: |
${{ runner.os }}-webpack-
- name: 🏗️ Build website
run: yarn build
working-directory: website

- name: 📦 Upload website build artifact
if: inputs.publish
uses: actions/upload-pages-artifact@v2
with:
path: website/build
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Continuous integration
name: Shared - Continuous Integration for common tasks

on:
workflow_dispatch:
push:
branches:
- main
merge_group:
pull_request:
branches:
- main
workflow_call:
inputs:
publish:
default: false
type: boolean

jobs:
checks:
Expand All @@ -25,7 +22,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
- name: ⚙️ Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
Expand All @@ -40,7 +37,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: ⚙️ Install dependencies
Expand All @@ -52,7 +49,7 @@ jobs:
uses: actions/cache@v3
with:
path: tools/cache
key: ${{ runner.os }}-tools-${{ matrix.php-versions }}-${{ github.sha }}
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
Expand All @@ -73,18 +70,9 @@ jobs:
with:
file: ./build/logs/clover.xml

- name: 📃 Generate documentation
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.stable
env:
GITHUB_TOKEN: ${{ secrets.GH_PRIVATE_ACCESS_TOKEN }}
run: |
composer generate-docs
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor }}"
echo `git add -A && git commit -m "docs: update documentation"`
git push --follow-tags origin main
build-website:
needs: checks
name: Check that website is building without errors
uses: ./.github/workflows/build-website.yml
uses: ./.github/workflows/__build-website.yml
with:
publish: ${{ inputs.publish }}
43 changes: 0 additions & 43 deletions .github/workflows/build-website.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Linter"

on:
push:
branches: [main, 4.x]
tags: ["*"]

pull_request:
branches: [main, 4.x]

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/[email protected]
51 changes: 51 additions & 0 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Main - Continuous Integration

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
- 4.x

jobs:
ci:
name: Continuous Integration
uses: ./.github/workflows/__shared-ci.yml
secrets: inherit
with:
publish: true

deploy:
name: Deploy website
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: documentation

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "docs: update documentation"
commit_options: "--no-verify --signoff"

- name: ⚙️ Setup Pages
if: github.ref == 'refs/heads/main'
uses: actions/configure-pages@v4

- name: 🚀 Deploy to GitHub Pages
id: deployment
if: github.ref == 'refs/heads/main'
uses: actions/deploy-pages@v3
21 changes: 21 additions & 0 deletions .github/workflows/need-fix-to-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Need fix to Issue

on:
push:
branches:
- main
workflow_dispatch:
inputs:
manual-commit-ref:
description: "The SHA of the commit to get the diff for"
required: true
manual-base-ref:
description: "By default, the commit entered above is compared to the one directly before it; to go back further, enter an earlier SHA here"
required: false

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/[email protected]
with:
manual-commit-ref: ${{ inputs.manual-commit-ref }}
manual-base-ref: ${{ inputs.manual-base-ref }}
13 changes: 0 additions & 13 deletions .github/workflows/publish.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Pull request - Continuous Integration

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- 4.x
merge_group:

jobs:
ci:
name: Continuous Integration
uses: ./.github/workflows/__shared-ci.yml
secrets: inherit
Loading

0 comments on commit d162cc9

Please sign in to comment.