From fc9401c1954c6cc5c33cc82ee27441dfbe922b99 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 26 Jun 2024 12:00:40 -0300 Subject: [PATCH] chore: Add GitHub workflows for JavaScript and Python autofix This commit adds GitHub workflows for JavaScript and Python autofix. The JavaScript workflow is triggered on pull requests and pushes to the main branch, specifically for changes in the "src/frontend" directory. It checks out the code, sets up Node.js, caches Node.js dependencies, installs Node.js dependencies, and runs Prettier for code formatting. The Python workflow is also triggered on pull requests and pushes to the main branch, but for changes in the "poetry.lock", "pyproject.toml", "src/backend", and "tests" directories. It checks out the code, installs Ruff, and runs Mypy for type checking and code formatting. --- .github/workflows/js_autofix.yml | 50 ++++++++++++++++++++++++++++++++ .github/workflows/py_autofix.yml | 29 ++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/js_autofix.yml create mode 100644 .github/workflows/py_autofix.yml diff --git a/.github/workflows/js_autofix.yml b/.github/workflows/js_autofix.yml new file mode 100644 index 000000000..f6501baab --- /dev/null +++ b/.github/workflows/js_autofix.yml @@ -0,0 +1,50 @@ +name: autofix.ci + +on: + pull_request: + types: [opened, synchronize, reopened, auto_merge_enabled, auto_merge_disabled] + paths: + - "src/frontend/**" + push: + branches: [ "main" ] + paths: + - "src/frontend/**" + +permissions: + contents: read + +env: + NODE_VERSION: "21" +jobs: + autofix: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + id: setup-node + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache Node.js dependencies + uses: actions/cache@v4 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install Node.js dependencies + run: | + cd src/frontend + npm ci + if: ${{ steps.setup-node.outputs.cache-hit != 'true' }} + - name: Run Prettier + run: | + cd src/frontend + npm run format + + - uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a \ No newline at end of file diff --git a/.github/workflows/py_autofix.yml b/.github/workflows/py_autofix.yml new file mode 100644 index 000000000..53d40bb14 --- /dev/null +++ b/.github/workflows/py_autofix.yml @@ -0,0 +1,29 @@ +name: autofix.ci +on: + pull_request: + types: [opened, synchronize, reopened, auto_merge_enabled, auto_merge_disabled] + paths: + - "poetry.lock" + - "pyproject.toml" + - "src/backend/**" + - "tests/**" +env: + POETRY_VERSION: "1.8.2" + +jobs: + lint: + name: Run Mypy + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + - "3.12" + - "3.11" + - "3.10" + steps: + - uses: actions/checkout@v4 + - uses: install-pinned/ruff@6b463d795ce39011cc004438ae507ae56235e12a + - run: ruff --fix-only . + - run: ruff format . + + - uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a \ No newline at end of file