Skip to content

Commit

Permalink
NEW Add docs linting step
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Apr 3, 2024
1 parent a51e932 commit a76a667
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 18 deletions.
60 changes: 42 additions & 18 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
phplinting:
type: boolean
default: false
doclinting:
type: boolean
default: true

runs:
using: composite
Expand Down Expand Up @@ -160,26 +163,18 @@ runs:
echo "Missing .nvmrc"
exit 1
fi
wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh
php -r '
$hash = "dd4b116a7452fc3bb8c0e410ceac27e19b0ba0f900fe2f91818a95c12e92130fdfb8170fec170b9fb006d316f6386f2b";
if (hash_file("sha384", "install.sh") === $hash) {
echo "Installer verified";
} else {
echo "Installer corrupt";
unlink('install.sh');
}
echo PHP_EOL;
'
if [[ ! -f install.sh ]]; then
echo "Cannot install nvm"
# Remove any sneaky attempts to put __install-nvm.sh into pull-requests
if [[ -f __install-nvm.sh ]]; then
rm __install-nvm.sh
fi
# Install nvm
cp ${{ github.action_path }}/install-nvm.sh __install-nvm.sh
chmod +x __install-nvm.sh
./__install-nvm.sh
if [[ $? != 0 ]]; then
echo "Error while installing nvm"
exit 1
fi
. install.sh
rm install.sh
export NVM_DIR="$HOME/.nvm"
# this loads nvm into the current terminal
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh"
ADMIN_NPM_VERSION=
if [[ -d vendor/silverstripe/admin ]]; then
cd vendor/silverstripe/admin
Expand Down Expand Up @@ -281,3 +276,32 @@ runs:
phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml
./codecov-linux -f coverage.xml;
echo "coverage.xml generated and uploaded to codecov"
- name: "Run documentation linting"
if: ${{ inputs.doclinting == 'true' }}
shell: bash
run: |
echo "Running documentation linting"
if [[ ! -f vendor/silverstripe/documentation-lint/.nvmrc ]]; then
echo "File vendor/silverstripe/documentation-lint/.nvmrc is missing. Check dependencies."
exit 1
fi
# Remove any sneaky attempts to put __install-nvm.sh into pull-requests
if [[ -f __install-nvm.sh ]]; then
rm __install-nvm.sh
fi
# Install nvm
cp ${{ github.action_path }}/install-nvm.sh __install-nvm.sh
chmod +x __install-nvm.sh
./__install-nvm.sh
if [[ $? != 0 ]]; then
echo "Error while installing nvm"
exit 1
fi
# Swap to correct version and make sure yarn is installed
NPM_VERSION=$(cat vendor/silverstripe/documentation-lint/.nvmrc)
nvm install $NPM_VERSION && nvm use $NPM_VERSION
npm install --global yarn
# Run the linting script
vendor/bin/ss-docs-lint
echo "Passed"
22 changes: 22 additions & 0 deletions install-nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh
php -r '
$hash = "dd4b116a7452fc3bb8c0e410ceac27e19b0ba0f900fe2f91818a95c12e92130fdfb8170fec170b9fb006d316f6386f2b";
if (hash_file("sha384", "install.sh") === $hash) {
echo "Installer verified";
} else {
echo "Installer corrupt";
unlink('install.sh');
}
echo PHP_EOL;
'
if [[ ! -f install.sh ]]; then
echo "Cannot install nvm"
exit 1
fi
. install.sh
rm install.sh
export NVM_DIR="$HOME/.nvm"
# this loads nvm into the current terminal
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh"

0 comments on commit a76a667

Please sign in to comment.