|
| 1 | +name: Quality Control |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: [ sync, stable ] |
| 6 | + pull_request: |
| 7 | + branches-ignore: [ sync, stable ] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.actor }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + detect-changes: |
| 15 | + name: Detect changes |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + code: ${{ steps.filter.outputs.code }} |
| 19 | + steps: |
| 20 | + |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - uses: dorny/paths-filter@v3 |
| 24 | + id: filter |
| 25 | + with: |
| 26 | + filters: | |
| 27 | + code: |
| 28 | + - 'colors/**' |
| 29 | + - 'lua/**' |
| 30 | + - 'tests/**' |
| 31 | +
|
| 32 | + tests: |
| 33 | + name: Run tests |
| 34 | + needs: detect-changes |
| 35 | + # Run only if testable code has changed (to save time and resources) |
| 36 | + if: ${{ needs.detect-changes.outputs.code == 'true' }} |
| 37 | + timeout-minutes: 15 |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + os: [ ubuntu-latest ] |
| 42 | + neovim_version: [ 'v0.9.5', 'v0.10.4', 'v0.11.5', 'nightly' ] |
| 43 | + include: |
| 44 | + - os: macos-latest |
| 45 | + neovim_version: v0.11.5 |
| 46 | + - os: windows-latest |
| 47 | + neovim_version: v0.11.5 |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + |
| 50 | + steps: |
| 51 | + |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup neovim |
| 55 | + uses: rhysd/action-setup-vim@v1 |
| 56 | + with: |
| 57 | + neovim: true |
| 58 | + version: ${{ matrix.neovim_version }} |
| 59 | + |
| 60 | + - name: Run tests |
| 61 | + run: make test |
| 62 | + |
| 63 | + lint-gendoc: |
| 64 | + name: Lint document generation |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Install Neovim |
| 71 | + uses: rhysd/action-setup-vim@v1 |
| 72 | + with: |
| 73 | + neovim: true |
| 74 | + version: v0.11.5 |
| 75 | + |
| 76 | + - name: Generate documentation |
| 77 | + run: make --silent documentation |
| 78 | + |
| 79 | + - name: Check for changes |
| 80 | + run: if [[ -n $(git status -s) ]]; then exit 1; fi |
| 81 | + |
| 82 | + lint-formatting: |
| 83 | + name: Lint formatting |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - uses: JohnnyMorganz/stylua-action@v4 |
| 90 | + with: |
| 91 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + version: v2.1.0 |
| 93 | + # CLI arguments |
| 94 | + args: --color always --respect-ignores --check . |
| 95 | + |
| 96 | + lint-commit: |
| 97 | + name: Lint commits |
| 98 | + runs-on: ubuntu-latest |
| 99 | + env: |
| 100 | + LINTCOMMIT_STRICT: true |
| 101 | + steps: |
| 102 | + |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + with: |
| 105 | + fetch-depth: 0 |
| 106 | + ref: ${{ github.event.pull_request.head.sha || github.ref }} |
| 107 | + |
| 108 | + - name: Install Neovim |
| 109 | + uses: rhysd/action-setup-vim@v1 |
| 110 | + with: |
| 111 | + neovim: true |
| 112 | + version: v0.11.5 |
| 113 | + |
| 114 | + - name: Lint new commits |
| 115 | + run: make --silent lintcommit-ci |
| 116 | + |
| 117 | + lint-filename: |
| 118 | + name: Lint filename lengths |
| 119 | + runs-on: ubuntu-latest |
| 120 | + steps: |
| 121 | + |
| 122 | + - uses: actions/checkout@v4 |
| 123 | + |
| 124 | + - name: Check filename legnths |
| 125 | + run: make --silent lint-filename-length-ci |
| 126 | + |
| 127 | + - name: Check case sensitivity |
| 128 | + |
| 129 | + |
| 130 | + check-workflow-status: |
| 131 | + name: Check workflow status |
| 132 | + runs-on: ubuntu-latest |
| 133 | + needs: [ tests, lint-gendoc, lint-formatting, lint-commit, lint-filename ] |
| 134 | + if: always() |
| 135 | + steps: |
| 136 | + - name: Check workflow status |
| 137 | + run: | |
| 138 | + exit_on_result() { |
| 139 | + if [[ "$2" == "failure" || "$2" == "cancelled" ]]; then |
| 140 | + echo "Job '$1' failed or was cancelled." |
| 141 | + exit 1 |
| 142 | + fi |
| 143 | + } |
| 144 | + exit_on_result "tests" "${{ needs.tests.result }}" |
| 145 | + exit_on_result "lint-gendoc" "${{ needs.lint-gendoc.result }}" |
| 146 | + exit_on_result "lint-formatting" "${{ needs.lint-formatting.result }}" |
| 147 | + exit_on_result "lint-commit" "${{ needs.lint-commit.result }}" |
| 148 | + exit_on_result "lint-filename" "${{ needs.lint-filename.result }}" |
0 commit comments