Skip to content

CI

CI #828

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
ci:
runs-on: ubuntu-latest
strategy:
# set fail-fast to false prevent one matrix job from cancelling other matrix jobs
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
lint_lang: [ 'lint-md', 'lint-js', 'lint-php' ]
name: ${{ matrix.lint_lang }}
steps:
- name: Checkout code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Install PHP
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: 8.1
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --ansi --no-interaction --optimize-autoloader
- name: Read .nvmrc
if: ${{ matrix.lint_lang == 'lint-md' || matrix.lint_lang == 'lint-js' }}
id: read-nvm
run: |
NPM_VERSION=$(cat vendor/silverstripe/documentation-lint/.nvmrc)
echo "version=$NPM_VERSION" >> $GITHUB_OUTPUT
- name: Install NPM
if: ${{ matrix.lint_lang == 'lint-md' || matrix.lint_lang == 'lint-js' }}
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ steps.read-nvm.outputs.version }}
- name: Install yarn
if: ${{ matrix.lint_lang == 'lint-md' || matrix.lint_lang == 'lint-js' }}
run: |
npm install --global yarn
- name: Run lint
run: |
LINT_LANG=${{ matrix.lint_lang }}
# Use string substitution to pull the "lint-" off the beginning of the `LINT_LANG` variable
# and add the "--with-" prefix so we have the correct flag for the language, e.g. "--with-md" from "lint-md"
FLAG="--with-${LINT_LANG#lint-}"
# Run the script
vendor/bin/doclint $FLAG