Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add docs linting step #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 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,23 +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
emteknetnz marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down Expand Up @@ -281,3 +279,43 @@ 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
emteknetnz marked this conversation as resolved.
Show resolved Hide resolved
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
export NVM_DIR="$HOME/.nvm"
# this loads nvm into the current terminal
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh"
# 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/doclint
echo "Passed"

- name: Delete temporary files
shell: bash
if: always()
run: |
if [[ -f __install-nvm.sh ]]; then
rm __install-nvm.sh
fi
19 changes: 19 additions & 0 deletions install-nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh
emteknetnz marked this conversation as resolved.
Show resolved Hide resolved
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
Loading