| 1 |
name: CI |
| 2 |
|
| 3 |
on: [push, pull_request] |
| 4 |
|
| 5 |
env: |
| 6 |
CI: true |
| 7 |
|
| 8 |
permissions: |
| 9 |
contents: read |
| 10 |
|
| 11 |
jobs: |
| 12 |
build: |
| 13 |
name: Build libllhttp.a |
| 14 |
runs-on: ${{ matrix.os }} |
| 15 |
strategy: |
| 16 |
matrix: |
| 17 |
os: |
| 18 |
- macos-latest |
| 19 |
- ubuntu-latest |
| 20 |
- windows-latest |
| 21 |
steps: |
| 22 |
- name: Install clang for Windows |
| 23 |
if: runner.os == 'Windows' |
| 24 |
run: | |
| 25 |
iwr -useb get.scoop.sh -outfile 'install.ps1' |
| 26 |
.\install.ps1 -RunAsAdmin |
| 27 |
scoop install llvm --global |
| 28 |
|
| 29 |
# Scoop modifies the PATH so we make the modified PATH global. |
| 30 |
echo $env:PATH >> $env:GITHUB_PATH |
| 31 |
|
| 32 |
- name: Fetch code |
| 33 |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 |
| 34 |
with: |
| 35 |
fetch-depth: 1 |
| 36 |
|
| 37 |
# Skip macOS & Windows, cache there is slower |
| 38 |
- name: Restore node_modules cache for Linux |
| 39 |
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 |
| 40 |
if: runner.os == 'Linux' |
| 41 |
with: |
| 42 |
path: ~/.npm |
| 43 |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 44 |
restore-keys: | |
| 45 |
${{ runner.os }}-node- |
| 46 |
|
| 47 |
- name: Install dependencies |
| 48 |
run: npm ci --ignore-scripts |
| 49 |
|
| 50 |
- name: Build libllhttp.a |
| 51 |
shell: bash |
| 52 |
run: | |
| 53 |
make build/libllhttp.a |
| 54 |
|
| 55 |
test: |
| 56 |
name: Run tests |
| 57 |
runs-on: ${{ matrix.os }} |
| 58 |
strategy: |
| 59 |
matrix: |
| 60 |
os: |
| 61 |
- macos-latest |
| 62 |
- ubuntu-latest |
| 63 |
- windows-latest |
| 64 |
steps: |
| 65 |
- name: Install clang for Windows |
| 66 |
if: runner.os == 'Windows' |
| 67 |
run: | |
| 68 |
iwr -useb get.scoop.sh -outfile 'install.ps1' |
| 69 |
.\install.ps1 -RunAsAdmin |
| 70 |
scoop install llvm --global |
| 71 |
|
| 72 |
# Scoop modifies the PATH so we make the modified PATH global. |
| 73 |
echo $env:PATH >> $env:GITHUB_PATH |
| 74 |
|
| 75 |
- name: Fetch code |
| 76 |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 |
| 77 |
with: |
| 78 |
fetch-depth: 1 |
| 79 |
|
| 80 |
# Skip macOS & Windows, cache there is slower |
| 81 |
- name: Restore node_modules cache for Linux |
| 82 |
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 |
| 83 |
if: runner.os == 'Linux' |
| 84 |
with: |
| 85 |
path: ~/.npm |
| 86 |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 87 |
restore-keys: | |
| 88 |
${{ runner.os }}-node- |
| 89 |
|
| 90 |
- name: Install dependencies |
| 91 |
run: npm ci --ignore-scripts |
| 92 |
|
| 93 |
# Custom script, because progress looks not good in CI |
| 94 |
- name: Run tests |
| 95 |
run: npm run test |
| 96 |
|
| 97 |
lint: |
| 98 |
name: Run ESLint |
| 99 |
runs-on: ubuntu-latest |
| 100 |
steps: |
| 101 |
- name: Fetch code |
| 102 |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 |
| 103 |
with: |
| 104 |
fetch-depth: 1 |
| 105 |
|
| 106 |
- name: Restore node_modules cache |
| 107 |
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 |
| 108 |
with: |
| 109 |
path: ~/.npm |
| 110 |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 111 |
restore-keys: | |
| 112 |
${{ runner.os }}-node- |
| 113 |
|
| 114 |
- name: Install dependencies |
| 115 |
run: npm ci --ignore-scripts |
| 116 |
|
| 117 |
- name: Run lint command |
| 118 |
run: npm run lint |