From 0b5c0f0c405dd009def4b6de8e430af38aaeb8e8 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 18:04:56 -0500 Subject: [PATCH] fix(ci): only run luarocks build on successful ci --- .github/workflows/ci.yaml | 111 ++++++++++++++++++++++++++++++++ .github/workflows/luarocks.yaml | 21 +++--- 2 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..fea1ba2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,111 @@ +name: ci +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + changes: + runs-on: ubuntu-latest + outputs: + lua: ${{ steps.changes.outputs.lua }} + python: ${{ steps.changes.outputs.python }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + lua: + - 'lua/**' + - 'spec/**' + - 'plugin/**' + - 'after/**' + - 'ftdetect/**' + - '*.lua' + - '.luarc.json' + - 'stylua.toml' + - 'selene.toml' + python: + - 'scripts/**' + - 'scrapers/**' + - 'tests/**' + - 'pyproject.toml' + - 'uv.lock' + + lua-format: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: 2.1.0 + args: --check . + + lua-lint: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: NTBBloodbath/selene-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --display-style quiet . + + lua-typecheck: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: mrcjkb/lua-typecheck-action@v0 + with: + checklevel: Warning + directories: lua + configpath: .luarc.json + + python-format: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv tool install ruff + - run: ruff format --check . + + python-lint: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv tool install ruff + - run: ruff check . + + python-typecheck: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv sync --dev + - run: uvx ty check . + + python-test: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv sync --dev + - run: uv run camoufox fetch + - run: uv run pytest tests/ -v diff --git a/.github/workflows/luarocks.yaml b/.github/workflows/luarocks.yaml index c64568f..b9bf08f 100644 --- a/.github/workflows/luarocks.yaml +++ b/.github/workflows/luarocks.yaml @@ -1,18 +1,17 @@ -name: Release - +name: luarocks on: - push: - tags: - - '*' - workflow_dispatch: - + workflow_run: + workflows: ["ci"] + types: + - completed jobs: - publish-luarocks: - name: Publish to LuaRocks + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Publish to LuaRocks - uses: nvim-neorocks/luarocks-tag-release@v7 + with: + ref: ${{ github.event.workflow_run.head_sha }} + - uses: nvim-neorocks/luarocks-tag-release@v7 env: LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}