ge-hch.5.15.15: add risk scorer tests #187
Workflow file for this run
This file contains hidden or 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: validate-story | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| jobs: | |
| detect: | |
| name: Detect non-markdown changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| run_validate: ${{ steps.detect.outputs.run_validate }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine base ref | |
| id: base | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "base=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT" | |
| elif [ -n "${{ github.event.before }}" ] && [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then | |
| echo "base=${{ github.event.before }}" >> "$GITHUB_OUTPUT" | |
| else | |
| if git rev-parse HEAD^ >/dev/null 2>&1; then | |
| echo "base=$(git rev-parse HEAD^)" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "base=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| fi | |
| fi | |
| - name: Detect non-markdown changes | |
| id: detect | |
| run: | | |
| set -euo pipefail | |
| base_ref="${{ steps.base.outputs.base }}" | |
| changed_files=$(git diff --name-only "$base_ref"...HEAD || true) | |
| if [ -z "$changed_files" ]; then | |
| run_validate=true | |
| else | |
| non_md=$(printf "%s\n" "$changed_files" | grep -vE '\.md$' || true) | |
| if [ -z "$non_md" ]; then | |
| run_validate=false | |
| else | |
| run_validate=true | |
| fi | |
| fi | |
| { | |
| echo "run_validate=${run_validate}" | |
| printf 'changed_files<<EOF\n%s\nEOF\n' "$changed_files" | |
| } >> "$GITHUB_OUTPUT" | |
| validate: | |
| needs: detect | |
| if: needs.detect.outputs.run_validate == 'true' | |
| runs-on: ubuntu-latest | |
| env: | |
| CI: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Prepare results dir | |
| run: mkdir -p results | |
| - name: Run validate-story | |
| run: node scripts/validate-story.js --glob "web/stories/**/*.ink" --max-steps 500 --output results/validate-story.json | |
| - name: Upload results | |
| if: failure() || always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validate-story-results | |
| path: results/** | |
| if-no-files-found: ignore |