style.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: Setup NodeJS
  62. uses: actions/setup-node@v4
  63. if: steps.changed-files.outputs.any_changed == 'true'
  64. with:
  65. node-version: 20
  66. cache: yarn
  67. cache-dependency-path: ./web/package.json
  68. - name: Web dependencies
  69. if: steps.changed-files.outputs.any_changed == 'true'
  70. run: yarn install --frozen-lockfile
  71. - name: Web style check
  72. if: steps.changed-files.outputs.any_changed == 'true'
  73. run: yarn run lint
  74. docker-compose-template:
  75. name: Docker Compose Template
  76. runs-on: ubuntu-latest
  77. steps:
  78. - name: Checkout code
  79. uses: actions/checkout@v4
  80. with:
  81. fetch-depth: 0
  82. persist-credentials: false
  83. - name: Check changed files
  84. id: changed-files
  85. uses: tj-actions/changed-files@v45
  86. with:
  87. files: |
  88. docker/generate_docker_compose
  89. docker/.env.example
  90. docker/docker-compose-template.yaml
  91. docker/docker-compose.yaml
  92. - name: Generate Docker Compose
  93. if: steps.changed-files.outputs.any_changed == 'true'
  94. run: |
  95. cd docker
  96. ./generate_docker_compose
  97. - name: Check for changes
  98. if: steps.changed-files.outputs.any_changed == 'true'
  99. run: git diff --exit-code
  100. superlinter:
  101. name: SuperLinter
  102. runs-on: ubuntu-latest
  103. steps:
  104. - name: Checkout code
  105. uses: actions/checkout@v4
  106. with:
  107. fetch-depth: 0
  108. persist-credentials: false
  109. - name: Check changed files
  110. id: changed-files
  111. uses: tj-actions/changed-files@v45
  112. with:
  113. files: |
  114. **.sh
  115. **.yaml
  116. **.yml
  117. **Dockerfile
  118. dev/**
  119. - name: Super-linter
  120. uses: super-linter/super-linter/slim@v7
  121. if: steps.changed-files.outputs.any_changed == 'true'
  122. env:
  123. BASH_SEVERITY: warning
  124. DEFAULT_BRANCH: main
  125. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  126. IGNORE_GENERATED_FILES: true
  127. IGNORE_GITIGNORED_FILES: true
  128. VALIDATE_BASH: true
  129. VALIDATE_BASH_EXEC: true
  130. # FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck
  131. # VALIDATE_GITHUB_ACTIONS: true
  132. VALIDATE_DOCKERFILE_HADOLINT: true
  133. VALIDATE_XML: true
  134. VALIDATE_YAML: true