Skip to content

base: add mdc to documentation CI. (#665) #1786

base: add mdc to documentation CI. (#665)

base: add mdc to documentation CI. (#665) #1786

Workflow file for this run

name: Deno CI
on:
push:
branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.mdc"
pull_request:
branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.mdc"
permissions:
contents: read
jobs:
# Check changed files to determine which package tests to run
check-changes:
runs-on: ubuntu-latest
outputs:
run-all: ${{ steps.changes.outputs.run-all }}
packages: ${{ steps.changes.outputs.packages }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changes
id: changes
run: |
# Get diff from previous commit
if [ "${{ github.event_name }}" = "push" ]; then
# For push: diff from previous commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
else
# For PR: diff from base branch
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
fi
echo "Changed files:"
echo "$CHANGED_FILES"
# Run all tests if common, core, CI/CD files, or root files are changed
if echo "$CHANGED_FILES" | grep -E '^(packages/(common|core)/|\.github/|deno\.jsonc|\.gitignore|tsconfig\.json|npm/|utils/)'; then
echo "run-all=true" >> $GITHUB_OUTPUT
echo "packages=[]" >> $GITHUB_OUTPUT
else
# Only specific packages are changed
CHANGED_PACKAGES=$(echo "$CHANGED_FILES" | grep '^packages/' | cut -d'/' -f2 | sort -u | grep -v -E '^(common|core)$' | jq -R -s -c 'split("\n")[:-1]')
if [ "$CHANGED_PACKAGES" = "[]" ] || [ "$CHANGED_PACKAGES" = '[""]' ]; then
echo "run-all=false" >> $GITHUB_OUTPUT
echo "packages=[]" >> $GITHUB_OUTPUT
else
echo "run-all=false" >> $GITHUB_OUTPUT
echo "packages=$CHANGED_PACKAGES" >> $GITHUB_OUTPUT
fi
fi
# Job to run all tests
test-all:
needs: check-changes
if: needs.check-changes.outputs.run-all == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [2.x]
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.deno-version }}
- name: Run deno test
run: |
deno fmt --check
deno task test:deno
deno task cov > coverage.lcov
- uses: codecov/codecov-action@v2
if: matrix.deno-version == '2.x'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.lcov
flags: unittests
- name: Run deno publish (dry)
run: npx jsr publish --dry-run --allow-dirty
# Job to test only specific packages
test-packages:
needs: check-changes
if: needs.check-changes.outputs.run-all == 'false' && needs.check-changes.outputs.packages != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [2.x]
package: ${{ fromJson(needs.check-changes.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.deno-version }}
- name: Run package-specific deno test
run: |
deno fmt --check packages/${{ matrix.package }}
deno task test:deno:${{ matrix.package }}
deno task check:${{ matrix.package }}
- name: Run deno publish (dry) for package
run: |
cd packages/${{ matrix.package }}
npx jsr publish --dry-run --allow-dirty