style.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. name: Style check
  2. on:
  3. pull_request:
  4. branches:
  5. - main
  6. concurrency:
  7. group: style-${{ github.head_ref || github.run_id }}
  8. cancel-in-progress: true
  9. jobs:
  10. python-style:
  11. name: Python Style
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v4
  16. - name: Check changed files
  17. id: changed-files
  18. uses: tj-actions/changed-files@v45
  19. with:
  20. files: |
  21. api/**
  22. .github/workflows/style.yml
  23. - name: Setup Poetry and Python
  24. if: steps.changed-files.outputs.any_changed == 'true'
  25. uses: ./.github/actions/setup-poetry
  26. - name: Install dependencies
  27. if: steps.changed-files.outputs.any_changed == 'true'
  28. run: poetry install -C api --only lint
  29. - name: Ruff check
  30. if: steps.changed-files.outputs.any_changed == 'true'
  31. run: |
  32. poetry run -C api ruff --version
  33. poetry run -C api ruff check ./api
  34. poetry run -C api ruff format --check ./api
  35. - name: Dotenv check
  36. if: steps.changed-files.outputs.any_changed == 'true'
  37. run: poetry run -C api dotenv-linter ./api/.env.example ./web/.env.example
  38. - name: Lint hints
  39. if: failure()
  40. run: echo "Please run 'dev/reformat' to fix the fixable linting errors."
  41. web-style:
  42. name: Web Style
  43. runs-on: ubuntu-latest
  44. defaults:
  45. run:
  46. working-directory: ./web
  47. steps:
  48. - name: Checkout code
  49. uses: actions/checkout@v4
  50. - name: Check changed files
  51. id: changed-files
  52. uses: tj-actions/changed-files@v45
  53. with:
  54. files: web/**
  55. - name: Setup NodeJS
  56. uses: actions/setup-node@v4
  57. if: steps.changed-files.outputs.any_changed == 'true'
  58. with:
  59. node-version: 20
  60. cache: yarn
  61. cache-dependency-path: ./web/package.json
  62. - name: Web dependencies
  63. if: steps.changed-files.outputs.any_changed == 'true'
  64. run: yarn install --frozen-lockfile
  65. - name: Web style check
  66. if: steps.changed-files.outputs.any_changed == 'true'
  67. run: yarn run lint
  68. superlinter:
  69. name: SuperLinter
  70. runs-on: ubuntu-latest
  71. steps:
  72. - name: Checkout code
  73. uses: actions/checkout@v4
  74. - name: Check changed files
  75. id: changed-files
  76. uses: tj-actions/changed-files@v45
  77. with:
  78. files: |
  79. **.sh
  80. **.yaml
  81. **.yml
  82. **Dockerfile
  83. dev/**
  84. - name: Super-linter
  85. uses: super-linter/super-linter/slim@v7
  86. if: steps.changed-files.outputs.any_changed == 'true'
  87. env:
  88. BASH_SEVERITY: warning
  89. DEFAULT_BRANCH: main
  90. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  91. IGNORE_GENERATED_FILES: true
  92. IGNORE_GITIGNORED_FILES: true
  93. VALIDATE_BASH: true
  94. VALIDATE_BASH_EXEC: true
  95. # FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck
  96. # VALIDATE_GITHUB_ACTIONS: true
  97. VALIDATE_DOCKERFILE_HADOLINT: true
  98. VALIDATE_XML: true
  99. VALIDATE_YAML: true