|
1 |
| -name: Lint |
| 1 | +name: Lint and Test |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches: ["master"]
|
| 6 | + paths-ignore: |
| 7 | + - "**/*.md" |
| 8 | + - "docs/**" |
| 9 | + - "logs/**" |
| 10 | + - "result/**" |
6 | 11 | pull_request:
|
7 |
| - # The branches below must be a subset of the branches above |
8 | 12 | branches: ["master"]
|
| 13 | + paths-ignore: |
| 14 | + - "**/*.md" |
| 15 | + - "docs/**" |
| 16 | + - "logs/**" |
| 17 | + - "result/**" |
9 | 18 | schedule:
|
10 | 19 | - cron: "29 4 * * 1"
|
11 | 20 |
|
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
12 | 28 | jobs:
|
13 |
| - eslint: |
14 |
| - name: Run eslint scanning |
| 29 | + deps: |
| 30 | + name: Prepare dependencies |
15 | 31 | runs-on: ubuntu-latest
|
16 |
| - permissions: |
17 |
| - contents: read |
18 |
| - security-events: write |
19 |
| - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 32 | + timeout-minutes: 15 |
20 | 33 | steps:
|
21 | 34 | - name: Checkout code
|
22 | 35 | uses: actions/checkout@v4
|
23 |
| - |
24 |
| - - name: Add gyp dependencies |
| 36 | + - name: Add system libs for native modules |
25 | 37 | run: sudo apt update && sudo apt install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
|
26 |
| - |
27 |
| - - name: Install ESLint |
| 38 | + - name: Setup Bun |
28 | 39 | uses: oven-sh/setup-bun@v2
|
29 | 40 | with:
|
30 | 41 | bun-version: latest
|
31 |
| - |
32 |
| - - name: Run install |
| 42 | + - name: Cache Bun package downloads |
| 43 | + id: bun-cache |
| 44 | + uses: actions/cache@v4 |
| 45 | + with: |
| 46 | + path: | |
| 47 | + ~/.bun/install/cache |
| 48 | + key: ${{ runner.os }}-bun-cache-${{ hashFiles('bun.lock') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-bun-cache- |
| 51 | + - name: Cache node_modules |
| 52 | + id: node-modules-cache |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: | |
| 56 | + node_modules |
| 57 | + key: ${{ runner.os }}-node-modules-${{ hashFiles('bun.lock') }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-node-modules- |
| 60 | + - name: Install dependencies |
33 | 61 | run: bun install --frozen-lockfile
|
| 62 | + - name: Upload node_modules artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 66 | + path: node_modules |
| 67 | + if-no-files-found: warn |
34 | 68 |
|
| 69 | + lint: |
| 70 | + name: Lint |
| 71 | + needs: deps |
| 72 | + runs-on: ubuntu-latest |
| 73 | + timeout-minutes: 10 |
| 74 | + permissions: |
| 75 | + contents: read |
| 76 | + security-events: write |
| 77 | + actions: read |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + - name: Setup Bun |
| 82 | + uses: oven-sh/setup-bun@v2 |
| 83 | + with: |
| 84 | + bun-version: latest |
| 85 | + - name: Download node_modules artifact |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 89 | + path: node_modules |
35 | 90 | - name: Run ESLint
|
36 | 91 | run: bunx eslint . --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif
|
37 |
| - continue-on-error: true |
38 |
| - |
39 | 92 | - name: Upload analysis results to GitHub
|
| 93 | + if: always() |
40 | 94 | uses: github/codeql-action/upload-sarif@v3
|
41 | 95 | with:
|
42 | 96 | sarif_file: eslint-results.sarif
|
43 | 97 | wait-for-processing: true
|
| 98 | + |
| 99 | + format: |
| 100 | + name: Prettier Format Check |
| 101 | + needs: deps |
| 102 | + runs-on: ubuntu-latest |
| 103 | + timeout-minutes: 5 |
| 104 | + steps: |
| 105 | + - name: Checkout code |
| 106 | + uses: actions/checkout@v4 |
| 107 | + - name: Setup Bun |
| 108 | + uses: oven-sh/setup-bun@v2 |
| 109 | + with: |
| 110 | + bun-version: latest |
| 111 | + - name: Download node_modules artifact |
| 112 | + uses: actions/download-artifact@v4 |
| 113 | + with: |
| 114 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 115 | + path: node_modules |
| 116 | + - name: Check formatting |
| 117 | + run: bunx prettier --check . |
| 118 | + |
| 119 | + typecheck: |
| 120 | + name: Type Check |
| 121 | + needs: deps |
| 122 | + runs-on: ubuntu-latest |
| 123 | + timeout-minutes: 10 |
| 124 | + steps: |
| 125 | + - name: Checkout code |
| 126 | + uses: actions/checkout@v4 |
| 127 | + - name: Setup Bun |
| 128 | + uses: oven-sh/setup-bun@v2 |
| 129 | + with: |
| 130 | + bun-version: latest |
| 131 | + - name: Download node_modules artifact |
| 132 | + uses: actions/download-artifact@v4 |
| 133 | + with: |
| 134 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 135 | + path: node_modules |
| 136 | + - name: Run TypeScript type check |
| 137 | + run: bunx tsc --noEmit -p tsconfig.json |
| 138 | + |
| 139 | + build: |
| 140 | + name: Build |
| 141 | + needs: deps |
| 142 | + runs-on: ubuntu-latest |
| 143 | + timeout-minutes: 10 |
| 144 | + steps: |
| 145 | + - name: Checkout code |
| 146 | + uses: actions/checkout@v4 |
| 147 | + - name: Setup Bun |
| 148 | + uses: oven-sh/setup-bun@v2 |
| 149 | + with: |
| 150 | + bun-version: latest |
| 151 | + - name: Download node_modules artifact |
| 152 | + uses: actions/download-artifact@v4 |
| 153 | + with: |
| 154 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 155 | + path: node_modules |
| 156 | + - name: Build TypeScript |
| 157 | + run: bun run build |
| 158 | + - name: Upload build artifact (bin) |
| 159 | + if: always() |
| 160 | + uses: actions/upload-artifact@v4 |
| 161 | + with: |
| 162 | + name: build-bin-${{ github.sha }} |
| 163 | + path: bin |
| 164 | + if-no-files-found: ignore |
| 165 | + |
| 166 | + test: |
| 167 | + name: Unit Tests |
| 168 | + needs: deps |
| 169 | + runs-on: ubuntu-latest |
| 170 | + timeout-minutes: 15 |
| 171 | + steps: |
| 172 | + - name: Checkout code |
| 173 | + uses: actions/checkout@v4 |
| 174 | + - name: Add system libs for native modules (runtime) |
| 175 | + run: sudo apt update && sudo apt install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev |
| 176 | + - name: Setup Bun |
| 177 | + uses: oven-sh/setup-bun@v2 |
| 178 | + with: |
| 179 | + bun-version: latest |
| 180 | + - name: Download node_modules artifact |
| 181 | + uses: actions/download-artifact@v4 |
| 182 | + with: |
| 183 | + name: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }} |
| 184 | + path: node_modules |
| 185 | + - name: Run Unit Tests with coverage |
| 186 | + run: bun test --coverage |
| 187 | + - name: Upload coverage report |
| 188 | + if: always() |
| 189 | + uses: actions/upload-artifact@v4 |
| 190 | + with: |
| 191 | + name: coverage-${{ runner.os }}-${{ github.run_id }} |
| 192 | + path: | |
| 193 | + coverage |
| 194 | + if-no-files-found: ignore |
0 commit comments