From acf0eada7f1b5b593fbe2ab7c77b54c14534931d Mon Sep 17 00:00:00 2001 From: Raphael Mobis Tacla Date: Wed, 2 Sep 2026 19:10:16 -0300 Subject: [PATCH] add new workflow to fix formatting and generate uuids before linting --- .github/actions/fix-stuff/action.yml | 28 ++++ .github/workflows/fix-and-lint.yml | 165 +++++++++++++++++++++++ .github/workflows/lint-and-check-gen.yml | 67 --------- 3 files changed, 193 insertions(+), 67 deletions(-) create mode 100644 .github/actions/fix-stuff/action.yml create mode 100644 .github/workflows/fix-and-lint.yml delete mode 100644 .github/workflows/lint-and-check-gen.yml diff --git a/.github/actions/fix-stuff/action.yml b/.github/actions/fix-stuff/action.yml new file mode 100644 index 0000000..ed482ff --- /dev/null +++ b/.github/actions/fix-stuff/action.yml @@ -0,0 +1,28 @@ +name: Fix Formatting & Generate UUIDs +description: Fixes formatiting, generates missing UUUIDs and commits changes + +outputs: + changes_detected: + description: Whether any changes were detected after formatting and generating UUIDs + value: ${{ steps.commit-changes.outputs.changes_detected }} + +runs: + using: composite + steps: + - uses: ./.github/actions/setup + + - name: Format Code + shell: bash + run: npm run format + + - name: Generate UUIDs + shell: bash + run: npm run gen:uuids + + - name: Commit Formatted Code & Generated UUIDs + id: commit-changes + uses: stefanzweifel/git-auto-commit-action@v7 + with: + commit_user_name: osrs-taskbot + commit_user_email: r.mobis+taskbot@gmail.com + commit_message: "[skip-fix] format everything and generate missing UUIDs" diff --git a/.github/workflows/fix-and-lint.yml b/.github/workflows/fix-and-lint.yml new file mode 100644 index 0000000..253feb6 --- /dev/null +++ b/.github/workflows/fix-and-lint.yml @@ -0,0 +1,165 @@ +name: Fix & Lint + +on: + pull_request: + branches: ["main"] + +jobs: + check-sensitive: + name: Check for Sensitive Files + runs-on: ubuntu-latest + + outputs: + require_approval: ${{ steps.changed-sensitive.outputs.any_changed || false }} + skip_fix: ${{ contains(steps.skip-fix.outputs.commit_message, 'skip-fix') }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v7 + with: + fetch-depth: 2 + + - name: Check Changed Sensitive Files + id: changed-sensitive + if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + uses: tj-actions/changed-files@v47 + with: + files: | + .github/** + package*.json + **.mts + lefthook.yml + + - name: Get Latest Commit Message + id: skip-fix + run: | + echo 'commit_message<> $GITHUB_OUTPUT + git log -1 --pretty=%B ${{ github.event.pull_request.head.sha }} >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + fix: + name: Fix + runs-on: ubuntu-latest + needs: check-sensitive + if: | + always() && + needs.check-sensitive.outputs.skip_fix != 'true' && + needs.check-sensitive.outputs.require_approval == 'false' + + outputs: + changes_detected: ${{ steps.fix-stuff.outputs.changes_detected }} + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + token: ${{ secrets.ROBOT_GITHUB_TOKEN }} + ref: ${{ github.head_ref }} + + - name: Fix Stuff + id: fix-stuff + uses: ./.github/actions/fix-stuff + + fix-sensitive: + name: Fix (Sensitive) + runs-on: ubuntu-latest + environment: Require Approval + needs: check-sensitive + if: | + always() && + needs.check-sensitive.outputs.skip_fix != 'true' && + needs.check-sensitive.outputs.require_approval == 'true' + + outputs: + changes_detected: false + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + token: ${{ secrets.ROBOT_GITHUB_TOKEN }} + ref: ${{ github.head_ref }} + + - name: Fix Stuff + id: fix-stuff + uses: ./.github/actions/fix-stuff + + lint: + name: General Linting + needs: [fix, fix-sensitive] + if: | + always() && + needs.fix.outputs.changes_detected != 'true' && needs.fix-sensitive.outputs.changes_detected != 'true' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - uses: ./.github/actions/setup + + - name: Lint code + run: npm run lint:ultracite + + - name: Lint tasks + run: npm run lint:tasks + + - name: Lint schema + run: npm run lint:schema + + - name: Lint UUIDs + run: npm run lint:uuids + + lint-links: + name: Link Links + needs: [fix, fix-sensitive] + if: | + always() && + needs.fix.outputs.changes_detected != 'true' && needs.fix-sensitive.outputs.changes_detected != 'true' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - uses: ./.github/actions/setup + + - name: Cache + uses: actions/cache@v6 + with: + path: .cache + key: cache-${{ hashFiles('tiers/*.json') }} + restore-keys: | + cache- + + - name: Lint links + run: npm run lint:links + + check-types: + name: Check Typescript Types + needs: [fix, fix-sensitive] + if: | + always() && + needs.fix.outputs.changes_detected != 'true' && needs.fix-sensitive.outputs.changes_detected != 'true' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - uses: ./.github/actions/setup + + - name: Generate types + run: npm run gen:types + + - name: Ensure types are up to date + run: | + if [ -n "$(git status --porcelain)" ]; then + exit 1 + fi diff --git a/.github/workflows/lint-and-check-gen.yml b/.github/workflows/lint-and-check-gen.yml deleted file mode 100644 index 8ead877..0000000 --- a/.github/workflows/lint-and-check-gen.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Lint & Check Generation - -on: - pull_request: - branches: ["main"] - push: - branches: ["main"] - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - - uses: ./.github/actions/setup - - - name: Lint code - run: npm run lint:ultracite - - - name: Lint tasks - run: npm run lint:tasks - - - name: Lint schema - run: npm run lint:schema - - - name: Lint UUIDs - run: npm run lint:uuids - - lint-links: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - - uses: ./.github/actions/setup - - - name: Cache - uses: actions/cache@v6 - with: - path: .cache - key: cache-${{ hashFiles('tiers/*.json') }} - restore-keys: | - cache- - - - name: Lint links - run: npm run lint:links - - check-types: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - - uses: ./.github/actions/setup - - - name: Generate types - run: npm run gen:types - - - name: Ensure types are up to date - run: | - if [ -n "$(git status --porcelain)" ]; then - exit 1 - fi