Add Mircoworkers (#8260) #323
Workflow file for this run
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: Pull Request tests | |
on: pull_request | |
run-name: "${{github.event.pull_request.title}} (#${{ github.event.number }})" | |
concurrency: | |
group: ${{ github.event.number }} | |
cancel-in-progress: true | |
jobs: | |
node-tests: | |
name: JavaScript tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install --omit=optional | |
- name: Get modified files | |
id: diff | |
run: | | |
echo "::debug:: Fetching files from ${{ github.api_url }}/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files" | |
FILES=$(curl -s "${{ github.api_url }}/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files" | jq -r '.[] | select(.status != "removed") | .filename' | tr '\n' ' ') | |
ENTRIES=$(echo "$FILES" | tr ' ' '\n' | grep -E '^entries/.*\.json$' | tr '\n' ' ') | |
if [ -n "$ENTRIES" ]; then | |
echo "entries=${ENTRIES}" >> $GITHUB_OUTPUT | |
fi | |
IMAGES=$(echo "$FILES" | tr ' ' '\n' | grep -E '^img/.*$' | tr '\n' ' ') | |
if [ -n "IMAGES" ]; then | |
echo "images=${IMAGES}" >> $GITHUB_OUTPUT | |
fi | |
- name: Validate JSON structure | |
if: steps.diff.outputs.entries | |
run: node tests/json.js ${{ steps.diff.outputs.entries }} | |
- name: Validate file extensions and permissions | |
run: tests/validate-fs.sh | |
- name: Validate Language codes | |
if: steps.diff.outputs.entries | |
run: node tests/languages.js ${{ steps.diff.outputs.entries }} | |
- name: Validate Region codes | |
if: steps.diff.outputs.entries | |
run: node tests/regions.js ${{ steps.diff.outputs.entries }} | |
- name: Validate Categories | |
if: steps.diff.outputs.entries | |
run: node tests/categories.js ${{ steps.diff.outputs.entries }} | |
- name: Validate Images | |
if: ${{ steps.diff.outputs.entries || steps.diff.outputs.images }} | |
run: | | |
node tests/images.js | |
node tests/svg.js ${{ steps.diff.outputs.images }} | |
- name: Validate URL reachability | |
if: steps.diff.outputs.entries | |
run: node tests/urls.js ${{ steps.diff.outputs.entries }} | |
continue-on-error: true | |
external-tests: | |
name: External Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Call PR Validator | |
run: | | |
curl -s --fail-with-body "https://pr-validator.2fa.directory/${{ github.event.repository.name }}/${{ github.event.number }}/" \ | |
-H "Content-Type: application/json" |