Merge pull request #127 from filecoin-project/vesahc-patch-1 #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validation | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
json_validation: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check for new or modified JSON project files | |
id: check_files | |
run: | | |
JSON_COUNT=$(git diff --name-only HEAD^..HEAD | grep -c "content/projects/.*\.json" || true) | |
echo "::set-output name=count::$JSON_COUNT" | |
- name: Configure Node 16 | |
if: steps.check_files.outputs.count != '0' | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Cache npm dependencies | |
if: steps.check_files.outputs.count != '0' | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install npm dependencies | |
if: steps.check_files.outputs.count != '0' | |
run: npm ci | |
- name: Set script permissions | |
if: steps.check_files.outputs.count != '0' | |
run: chmod +x ./scripts/basic-validation.sh | |
- name: Validate JSON files | |
if: steps.check_files.outputs.count != '0' | |
run: ./scripts/basic-validation.sh | |
schema_validation: | |
needs: json_validation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check if JSON files are modified | |
id: check_files | |
run: | | |
JSON_COUNT=$(git diff --name-only HEAD^..HEAD | grep -c "content/projects/.*\.json" || true) | |
echo "::set-output name=count::$JSON_COUNT" | |
- name: Configure Node 16 | |
if: steps.check_files.outputs.count != '0' | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Install NPM dependencies | |
if: steps.check_files.outputs.count != '0' | |
run: npm ci | |
- name: Set script permissions | |
if: steps.check_files.outputs.count != '0' | |
run: chmod +x ./scripts/schema-validation.sh | |
- name: Validate JSON schema | |
if: steps.check_files.outputs.count != '0' | |
run: ./scripts/schema-validation.sh |