2024-01-04 15:37:51 +08:00
|
|
|
name: Style check
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
2024-01-09 10:31:52 +08:00
|
|
|
concurrency:
|
2024-05-31 16:42:14 +08:00
|
|
|
group: style-${{ github.head_ref || github.run_id }}
|
2024-01-09 10:31:52 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2024-01-04 15:37:51 +08:00
|
|
|
jobs:
|
2024-02-06 13:21:13 +08:00
|
|
|
python-style:
|
|
|
|
name: Python Style
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-06-04 03:03:18 +08:00
|
|
|
- name: Check changed files
|
|
|
|
id: changed-files
|
2024-09-10 09:13:48 +08:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-06-04 03:03:18 +08:00
|
|
|
with:
|
2024-11-08 17:30:26 +08:00
|
|
|
files: |
|
|
|
|
api/**
|
|
|
|
.github/workflows/style.yml
|
2024-06-04 03:03:18 +08:00
|
|
|
|
2024-11-08 17:30:26 +08:00
|
|
|
- name: Setup Poetry and Python
|
2024-11-06 13:55:29 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-11-08 17:30:26 +08:00
|
|
|
uses: ./.github/actions/setup-poetry
|
2024-11-06 13:55:29 +08:00
|
|
|
|
2024-11-08 17:30:26 +08:00
|
|
|
- name: Install dependencies
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-06-12 14:43:03 +08:00
|
|
|
run: poetry install -C api --only lint
|
2024-02-06 13:21:13 +08:00
|
|
|
|
|
|
|
- name: Ruff check
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-11-08 17:30:26 +08:00
|
|
|
run: |
|
|
|
|
poetry run -C api ruff check ./api
|
|
|
|
poetry run -C api ruff format --check ./api
|
2024-02-06 13:21:13 +08:00
|
|
|
|
2024-04-16 19:53:54 +08:00
|
|
|
- name: Dotenv check
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-06-12 14:43:03 +08:00
|
|
|
run: poetry run -C api dotenv-linter ./api/.env.example ./web/.env.example
|
2024-04-16 19:53:54 +08:00
|
|
|
|
2024-02-06 13:21:13 +08:00
|
|
|
- name: Lint hints
|
|
|
|
if: failure()
|
|
|
|
run: echo "Please run 'dev/reformat' to fix the fixable linting errors."
|
|
|
|
|
2024-06-04 03:03:18 +08:00
|
|
|
web-style:
|
|
|
|
name: Web Style
|
2024-01-04 15:37:51 +08:00
|
|
|
runs-on: ubuntu-latest
|
2024-06-04 03:03:18 +08:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./web
|
2024-01-04 15:37:51 +08:00
|
|
|
|
|
|
|
steps:
|
2024-01-09 18:15:25 +08:00
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
2024-06-04 03:03:18 +08:00
|
|
|
|
|
|
|
- name: Check changed files
|
|
|
|
id: changed-files
|
2024-09-10 09:13:48 +08:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-02-29 12:45:06 +08:00
|
|
|
with:
|
2024-06-04 03:03:18 +08:00
|
|
|
files: web/**
|
2024-01-09 18:15:25 +08:00
|
|
|
|
|
|
|
- name: Setup NodeJS
|
|
|
|
uses: actions/setup-node@v4
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-01-09 18:15:25 +08:00
|
|
|
with:
|
2024-01-18 19:12:40 +08:00
|
|
|
node-version: 20
|
2024-01-09 18:15:25 +08:00
|
|
|
cache: yarn
|
|
|
|
cache-dependency-path: ./web/package.json
|
|
|
|
|
|
|
|
- name: Web dependencies
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
run: yarn install --frozen-lockfile
|
2024-01-09 18:15:25 +08:00
|
|
|
|
|
|
|
- name: Web style check
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
run: yarn run lint
|
|
|
|
|
|
|
|
|
|
|
|
superlinter:
|
|
|
|
name: SuperLinter
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Check changed files
|
|
|
|
id: changed-files
|
2024-09-10 09:13:48 +08:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-06-04 03:03:18 +08:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
**.sh
|
|
|
|
**.yaml
|
|
|
|
**.yml
|
2024-06-22 01:34:08 +08:00
|
|
|
**Dockerfile
|
2024-06-14 20:54:07 +08:00
|
|
|
dev/**
|
2024-01-09 18:15:25 +08:00
|
|
|
|
|
|
|
- name: Super-linter
|
2024-09-10 09:13:48 +08:00
|
|
|
uses: super-linter/super-linter/slim@v7
|
2024-06-04 03:03:18 +08:00
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
2024-01-09 18:15:25 +08:00
|
|
|
env:
|
|
|
|
BASH_SEVERITY: warning
|
|
|
|
DEFAULT_BRANCH: main
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
IGNORE_GENERATED_FILES: true
|
|
|
|
IGNORE_GITIGNORED_FILES: true
|
|
|
|
VALIDATE_BASH: true
|
|
|
|
VALIDATE_BASH_EXEC: true
|
2024-06-22 01:34:08 +08:00
|
|
|
# FIXME: temporarily disabled until api-docker.yaml's run script is fixed for shellcheck
|
|
|
|
# VALIDATE_GITHUB_ACTIONS: true
|
2024-01-09 18:15:25 +08:00
|
|
|
VALIDATE_DOCKERFILE_HADOLINT: true
|
2024-06-03 13:39:54 +08:00
|
|
|
VALIDATE_XML: true
|
2024-01-09 18:15:25 +08:00
|
|
|
VALIDATE_YAML: true
|