name: Style check on: workflow_call: inputs: base-rev: required: true type: string classification-succeeded: description: Whether the caller successfully classified the changed files. required: true type: boolean run-python-style: description: Run Python style checks for the changed files. required: true type: boolean run-dify-agent-style: description: Run Dify Agent style checks for the changed files. required: true type: boolean run-web-style: description: Run Web style checks for the changed files. required: true type: boolean run-ts-common-style: description: Run shared TypeScript style checks for the changed files. required: true type: boolean run-superlinter: description: Run SuperLinter for the changed files. required: true type: boolean skip-checks: description: Create the required check runs without repeating previously successful work. required: false type: boolean default: false permissions: checks: write statuses: write contents: read jobs: python-style: name: Python Style if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-python-style || inputs.run-dify-agent-style) }} runs-on: depot-ubuntu-24.04 steps: - name: Verify changed-file classification if: ${{ !inputs.classification-succeeded }} run: | echo "Changed-file classification failed; refusing to skip Python style checks." >&2 exit 1 - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false fetch-depth: 0 - name: Setup UV and Python uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: enable-cache: false python-version: '3.12' cache-dependency-glob: | api/uv.lock dify-agent/uv.lock - name: Install dependencies if: inputs.run-python-style run: uv sync --project api --dev - name: Run Import Linter if: inputs.run-python-style run: uv run --directory api --dev lint-imports - name: Run Response Contract Linter if: inputs.run-python-style run: uv run --project api --dev python api/dev/lint_response_contracts.py --fail-on-mismatch - name: Run No New Getattr Guard if: inputs.run-python-style run: uv run --project api python scripts/check_no_new_getattr.py --base-rev "${{ inputs.base-rev }}" - name: Run No New Controller SQLAlchemy Guard if: inputs.run-python-style run: uv run --project api python scripts/check_no_new_controller_sqlalchemy.py --base-rev "${{ inputs.base-rev }}" - name: Run Type Checks if: inputs.run-python-style env: PYREFLY_OUTPUT_FORMAT: github run: make type-check-core - name: Run Dify Agent Ruff if: inputs.run-dify-agent-style run: make -C dify-agent check - name: Run Dify Agent Type Checks if: inputs.run-dify-agent-style run: make -C dify-agent typecheck - name: Dotenv check if: inputs.run-python-style run: uv run --project api dotenv-linter ./api/.env.example ./web/.env.example web-style: name: Web Style if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-web-style) }} runs-on: depot-ubuntu-24.04 defaults: run: working-directory: ./web permissions: checks: write pull-requests: read steps: - name: Verify changed-file classification if: ${{ !inputs.classification-succeeded }} working-directory: . run: | echo "Changed-file classification failed; refusing to skip Web style checks." >&2 exit 1 - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup web environment uses: ./.github/actions/setup-web - name: Web tsslint env: NODE_OPTIONS: --max-old-space-size=4096 run: vp run lint:tss - name: Web dead code check working-directory: . run: vp run knip - name: Web dead code check production working-directory: . run: vp run knip:production - name: Web production unused declarations check working-directory: . run: vp run knip:production-unused-check ts-common-style: name: TS Common if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-ts-common-style) }} runs-on: depot-ubuntu-24.04-4 permissions: checks: write pull-requests: read steps: - name: Verify changed-file classification if: ${{ !inputs.classification-succeeded }} run: | echo "Changed-file classification failed; refusing to skip TypeScript style checks." >&2 exit 1 - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup web environment uses: ./.github/actions/setup-web - name: Static check run: pnpm -w check superlinter: name: SuperLinter if: ${{ !inputs.skip-checks && (!inputs.classification-succeeded || inputs.run-superlinter) }} runs-on: depot-ubuntu-24.04 steps: - name: Verify changed-file classification if: ${{ !inputs.classification-succeeded }} run: | echo "Changed-file classification failed; refusing to skip SuperLinter." >&2 exit 1 - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - name: Super-linter uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0 env: BASH_SEVERITY: warning DEFAULT_BRANCH: origin/main EDITORCONFIG_FILE_NAME: editorconfig-checker.json ENABLE_GITHUB_PULL_REQUEST_SUMMARY_COMMENT: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} IGNORE_GENERATED_FILES: true IGNORE_GITIGNORED_FILES: true VALIDATE_ALL_CODEBASE: false VALIDATE_BASH: true VALIDATE_BASH_EXEC: true # FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck # VALIDATE_GITHUB_ACTIONS: true VALIDATE_DOCKERFILE_HADOLINT: true VALIDATE_EDITORCONFIG: true VALIDATE_XML: true VALIDATE_YAML: true