Commit e015b87f17
Unsigned
Layout: unified ยท split
.github/workflows/ci-api.yml added +216
| @@ -0,0 +1,216 @@ | ||
| 1 | # CI checks for the API, run on PRs touching api/ and manually via dispatch | |
| 2 | name: ๐ฆ API CI | |
| 3 | ||
| 4 | on: | |
| 5 | pull_request: | |
| 6 | paths: | |
| 7 | - 'api/**' | |
| 8 | - 'awesome-privacy.yml' | |
| 9 | - '.github/workflows/ci-api.yml' | |
| 10 | workflow_dispatch: | |
| 11 | ||
| 12 | permissions: | |
| 13 | contents: read | |
| 14 | ||
| 15 | concurrency: | |
| 16 | group: ${{ github.workflow }}-${{ github.ref }} | |
| 17 | cancel-in-progress: true | |
| 18 | ||
| 19 | jobs: | |
| 20 | lint: | |
| 21 | name: ๐ก๏ธ Lint | |
| 22 | runs-on: ubuntu-latest | |
| 23 | defaults: | |
| 24 | run: | |
| 25 | working-directory: api | |
| 26 | steps: | |
| 27 | - uses: actions/checkout@v6 | |
| 28 | with: | |
| 29 | persist-credentials: false | |
| 30 | - uses: oven-sh/setup-bun@v2 | |
| 31 | with: | |
| 32 | bun-version: latest | |
| 33 | - run: bun install --frozen-lockfile | |
| 34 | - run: bun run lint | |
| 35 | ||
| 36 | format: | |
| 37 | name: ๐ Format | |
| 38 | runs-on: ubuntu-latest | |
| 39 | defaults: | |
| 40 | run: | |
| 41 | working-directory: api | |
| 42 | steps: | |
| 43 | - uses: actions/checkout@v6 | |
| 44 | with: | |
| 45 | persist-credentials: false | |
| 46 | - uses: oven-sh/setup-bun@v2 | |
| 47 | with: | |
| 48 | bun-version: latest | |
| 49 | - run: bun install --frozen-lockfile | |
| 50 | - run: bun run format:check | |
| 51 | ||
| 52 | typecheck: | |
| 53 | name: ๐งฉ Typecheck | |
| 54 | runs-on: ubuntu-latest | |
| 55 | defaults: | |
| 56 | run: | |
| 57 | working-directory: api | |
| 58 | steps: | |
| 59 | - uses: actions/checkout@v6 | |
| 60 | with: | |
| 61 | persist-credentials: false | |
| 62 | - uses: oven-sh/setup-bun@v2 | |
| 63 | with: | |
| 64 | bun-version: latest | |
| 65 | - run: bun install --frozen-lockfile | |
| 66 | - run: bun run build:data | |
| 67 | - run: bun run typecheck | |
| 68 | ||
| 69 | test: | |
| 70 | name: ๐งช Test | |
| 71 | runs-on: ubuntu-latest | |
| 72 | defaults: | |
| 73 | run: | |
| 74 | working-directory: api | |
| 75 | steps: | |
| 76 | - uses: actions/checkout@v6 | |
| 77 | with: | |
| 78 | persist-credentials: false | |
| 79 | - uses: oven-sh/setup-bun@v2 | |
| 80 | with: | |
| 81 | bun-version: latest | |
| 82 | - run: bun install --frozen-lockfile | |
| 83 | - run: bun run build:data | |
| 84 | - run: bun run test | |
| 85 | ||
| 86 | build: | |
| 87 | name: ๐๏ธ Build | |
| 88 | runs-on: ubuntu-latest | |
| 89 | defaults: | |
| 90 | run: | |
| 91 | working-directory: api | |
| 92 | steps: | |
| 93 | - uses: actions/checkout@v6 | |
| 94 | with: | |
| 95 | persist-credentials: false | |
| 96 | - uses: oven-sh/setup-bun@v2 | |
| 97 | with: | |
| 98 | bun-version: latest | |
| 99 | - run: bun install --frozen-lockfile | |
| 100 | - run: bun run build | |
| 101 | - name: Verify bundle output | |
| 102 | run: test -f dist/index.workers.js || { echo "โ worker bundle not produced"; exit 1; } | |
| 103 | ||
| 104 | smoke: | |
| 105 | name: ๐จ Smoke Test | |
| 106 | runs-on: ubuntu-latest | |
| 107 | defaults: | |
| 108 | run: | |
| 109 | working-directory: api | |
| 110 | steps: | |
| 111 | - uses: actions/checkout@v6 | |
| 112 | with: | |
| 113 | persist-credentials: false | |
| 114 | - uses: oven-sh/setup-bun@v2 | |
| 115 | with: | |
| 116 | bun-version: latest | |
| 117 | - run: bun install --frozen-lockfile | |
| 118 | - run: bun run smoke | |
| 119 | ||
| 120 | docker-smoke: | |
| 121 | name: ๐ณ Docker Smoke | |
| 122 | runs-on: ubuntu-latest | |
| 123 | continue-on-error: true | |
| 124 | defaults: | |
| 125 | run: | |
| 126 | working-directory: api | |
| 127 | steps: | |
| 128 | - uses: actions/checkout@v6 | |
| 129 | with: | |
| 130 | persist-credentials: false | |
| 131 | - name: Build and run container | |
| 132 | run: bash tests/docker-smoke.sh | |
| 133 | timeout-minutes: 10 | |
| 134 | ||
| 135 | dependency-review: | |
| 136 | name: ๐ Dependency Audit | |
| 137 | runs-on: ubuntu-latest | |
| 138 | if: github.event_name == 'pull_request' | |
| 139 | steps: | |
| 140 | - uses: actions/checkout@v6 | |
| 141 | with: | |
| 142 | persist-credentials: false | |
| 143 | - uses: actions/dependency-review-action@v5 | |
| 144 | with: | |
| 145 | fail-on-severity: moderate | |
| 146 | ||
| 147 | secret-scan: | |
| 148 | name: ๐ Secret Scan | |
| 149 | runs-on: ubuntu-latest | |
| 150 | if: github.event_name == 'pull_request' | |
| 151 | steps: | |
| 152 | - uses: actions/checkout@v6 | |
| 153 | with: | |
| 154 | fetch-depth: 0 | |
| 155 | persist-credentials: false | |
| 156 | - name: Scan PR diff for secrets | |
| 157 | uses: trufflesecurity/trufflehog@v3.95.5 | |
| 158 | with: | |
| 159 | base: ${{ github.event.pull_request.base.sha }} | |
| 160 | head: ${{ github.event.pull_request.head.sha }} | |
| 161 | extra_args: --only-verified | |
| 162 | ||
| 163 | # Renders a markdown table of every check at the end | |
| 164 | summary: | |
| 165 | name: ๐ Summary | |
| 166 | runs-on: ubuntu-latest | |
| 167 | if: always() | |
| 168 | continue-on-error: true | |
| 169 | needs: | |
| 170 | - lint | |
| 171 | - format | |
| 172 | - typecheck | |
| 173 | - test | |
| 174 | - build | |
| 175 | - smoke | |
| 176 | - docker-smoke | |
| 177 | - dependency-review | |
| 178 | - secret-scan | |
| 179 | steps: | |
| 180 | - name: Render summary | |
| 181 | env: | |
| 182 | NEEDS: ${{ toJSON(needs) }} | |
| 183 | run: | | |
| 184 | label() { | |
| 185 | case "$1" in | |
| 186 | lint) echo "๐ก๏ธ Lint" ;; | |
| 187 | format) echo "๐ Format" ;; | |
| 188 | typecheck) echo "๐งฉ Typecheck" ;; | |
| 189 | test) echo "๐งช Test" ;; | |
| 190 | build) echo "๐๏ธ Build" ;; | |
| 191 | smoke) echo "๐จ Smoke Test" ;; | |
| 192 | docker-smoke) echo "๐ณ Docker Smoke" ;; | |
| 193 | dependency-review) echo "๐ Dependency Audit" ;; | |
| 194 | secret-scan) echo "๐ Secret Scan" ;; | |
| 195 | *) echo "$1" ;; | |
| 196 | esac | |
| 197 | } | |
| 198 | status() { | |
| 199 | case "$1" in | |
| 200 | success) echo "โ Passed" ;; | |
| 201 | skipped) echo "โญ๏ธ Skipped" ;; | |
| 202 | cancelled) echo "๐ซ Cancelled" ;; | |
| 203 | failure) [ "$2" = docker-smoke ] && echo "โ ๏ธ Warnings" || echo "โ Failed" ;; | |
| 204 | *) echo "โ $1" ;; | |
| 205 | esac | |
| 206 | } | |
| 207 | { | |
| 208 | echo "## API CI Summary" | |
| 209 | echo "" | |
| 210 | echo "| Check | Status |" | |
| 211 | echo "|-------|--------|" | |
| 212 | } >> "$GITHUB_STEP_SUMMARY" | |
| 213 | for job in $(echo "$NEEDS" | jq -r 'keys[]'); do | |
| 214 | result=$(echo "$NEEDS" | jq -r --arg j "$job" '.[$j].result') | |
| 215 | echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY" | |
| 216 | done | |
.github/workflows/deploy.yml added +57
| @@ -0,0 +1,57 @@ | ||
| 1 | name: ๐ Deploy API | |
| 2 | ||
| 3 | on: | |
| 4 | push: | |
| 5 | branches: [main] | |
| 6 | paths: | |
| 7 | - 'api/**' | |
| 8 | - 'awesome-privacy.yml' | |
| 9 | - '.github/workflows/deploy.yml' | |
| 10 | workflow_dispatch: | |
| 11 | ||
| 12 | permissions: | |
| 13 | contents: read | |
| 14 | ||
| 15 | concurrency: | |
| 16 | group: deploy-api-${{ github.ref }} | |
| 17 | cancel-in-progress: false | |
| 18 | ||
| 19 | jobs: | |
| 20 | checks: | |
| 21 | name: ๐งช Checks | |
| 22 | runs-on: ubuntu-latest | |
| 23 | defaults: | |
| 24 | run: | |
| 25 | working-directory: api | |
| 26 | steps: | |
| 27 | - uses: actions/checkout@v6 | |
| 28 | with: | |
| 29 | persist-credentials: false | |
| 30 | - uses: oven-sh/setup-bun@v2 | |
| 31 | with: | |
| 32 | bun-version: latest | |
| 33 | - run: bun install --frozen-lockfile | |
| 34 | - run: bun run build:data | |
| 35 | - run: bun run lint | |
| 36 | - run: bun run test | |
| 37 | ||
| 38 | deploy: | |
| 39 | name: โ๏ธ Deploy to Cloudflare | |
| 40 | needs: checks | |
| 41 | runs-on: ubuntu-latest | |
| 42 | defaults: | |
| 43 | run: | |
| 44 | working-directory: api | |
| 45 | steps: | |
| 46 | - uses: actions/checkout@v6 | |
| 47 | with: | |
| 48 | persist-credentials: false | |
| 49 | - uses: oven-sh/setup-bun@v2 | |
| 50 | with: | |
| 51 | bun-version: latest | |
| 52 | - run: bun install --frozen-lockfile | |
| 53 | - name: Build data and deploy worker | |
| 54 | env: | |
| 55 | CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| 56 | CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| 57 | run: bun run deploy | |