style.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. with:
  17. fetch-depth: 0
  18. persist-credentials: false
  19. - name: Check changed files
  20. id: changed-files
  21. uses: tj-actions/changed-files@v45
  22. with:
  23. files: |
  24. api/**
  25. .github/workflows/style.yml
  26. - name: Setup Poetry and Python
  27. if: steps.changed-files.outputs.any_changed == 'true'
  28. uses: ./.github/actions/setup-poetry
  29. - name: Install dependencies
  30. if: steps.changed-files.outputs.any_changed == 'true'
  31. run: poetry install -C api --only lint
  32. - name: Ruff check
  33. if: steps.changed-files.outputs.any_changed == 'true'
  34. run: |
  35. poetry run -C api ruff --version
  36. poetry run -C api ruff check ./
  37. poetry run -C api ruff format --check ./
  38. - name: Dotenv check
  39. if: steps.changed-files.outputs.any_changed == 'true'
  40. run: poetry run -P api dotenv-linter ./api/.env.example ./web/.env.example
  41. - name: Lint hints
  42. if: failure()
  43. run: echo "Please run 'dev/reformat' to fix the fixable linting errors."
  44. web-style:
  45. name: Web Style
  46. runs-on: ubuntu-latest
  47. defaults:
  48. run:
  49. working-directory: ./web
  50. steps:
  51. - name: Checkout code
  52. uses: actions/checkout@v4
  53. with:
  54. fetch-depth: 0
  55. persist-credentials: false
  56. - name: Check changed files
  57. id: changed-files
  58. uses: tj-actions/changed-files@v45
  59. with:
  60. files: web/**
  61. - name: Install pnpm
  62. uses: pnpm/action-setup@v4
  63. with:
  64. version: 10
  65. run_install: false
  66. - name: Setup NodeJS
  67. uses: actions/setup-node@v4
  68. if: steps.changed-files.outputs.any_changed == 'true'
  69. with:
  70. node-version: 20
  71. cache: pnpm
  72. cache-dependency-path: ./web/package.json
  73. - name: Web dependencies
  74. if: steps.changed-files.outputs.any_changed == 'true'
  75. run: pnpm install --frozen-lockfile
  76. - name: Web style check
  77. if: steps.changed-files.outputs.any_changed == 'true'
  78. run: pnpm run lint
  79. docker-compose-template:
  80. name: Docker Compose Template
  81. runs-on: ubuntu-latest
  82. steps:
  83. - name: Checkout code
  84. uses: actions/checkout@v4
  85. with:
  86. fetch-depth: 0
  87. persist-credentials: false
  88. - name: Check changed files
  89. id: changed-files
  90. uses: tj-actions/changed-files@v45
  91. with:
  92. files: |
  93. docker/generate_docker_compose
  94. docker/.env.example
  95. docker/docker-compose-template.yaml
  96. docker/docker-compose.yaml
  97. - name: Generate Docker Compose
  98. if: steps.changed-files.outputs.any_changed == 'true'
  99. run: |
  100. cd docker
  101. ./generate_docker_compose
  102. - name: Check for changes
  103. if: steps.changed-files.outputs.any_changed == 'true'
  104. run: git diff --exit-code
  105. superlinter:
  106. name: SuperLinter
  107. runs-on: ubuntu-latest
  108. steps:
  109. - name: Checkout code
  110. uses: actions/checkout@v4
  111. with:
  112. fetch-depth: 0
  113. persist-credentials: false
  114. - name: Check changed files
  115. id: changed-files
  116. uses: tj-actions/changed-files@v45
  117. with:
  118. files: |
  119. **.sh
  120. **.yaml
  121. **.yml
  122. **Dockerfile
  123. dev/**
  124. - name: Super-linter
  125. uses: super-linter/super-linter/slim@v7
  126. if: steps.changed-files.outputs.any_changed == 'true'
  127. env:
  128. BASH_SEVERITY: warning
  129. DEFAULT_BRANCH: main
  130. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  131. IGNORE_GENERATED_FILES: true
  132. IGNORE_GITIGNORED_FILES: true
  133. VALIDATE_BASH: true
  134. VALIDATE_BASH_EXEC: true
  135. # FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck
  136. # VALIDATE_GITHUB_ACTIONS: true
  137. VALIDATE_DOCKERFILE_HADOLINT: true
  138. VALIDATE_XML: true
  139. VALIDATE_YAML: true