Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

move CI checks into docker-compose services (#314)

* move CI checks into docker-compose services

* address PR feedback: reuse Dockerfile in codegen-check, broaden drift check, collapse per-step services

* split lint/build. backend targets server_base and client client base

authored by

Vinay Rao and committed by
GitHub
97d09d80 0e3223d5

+61 -25
+7 -21
.github/workflows/apply_pr_checks.yaml
··· 29 29 runs-on: ubuntu-latest 30 30 steps: 31 31 - uses: actions/checkout@v4 32 - - uses: actions/setup-node@v6 33 - with: 34 - node-version-file: '.nvmrc' 35 - cache: 'npm' 36 - - run: npm ci 37 - - name: Generate graphql 38 - run: | 39 - npm run generate 40 - if [[ -z "$(git status --porcelain)" ]]; then 41 - echo "Generated GraphQL is up to date." 42 - else 43 - echo "GraphQL re-generation required!!" 44 - echo "::error:: $(git status)" 45 - exit 1 46 - fi 32 + - name: Check generated GraphQL is up to date 33 + run: docker compose run --rm --quiet-pull codegen-check 47 34 48 35 check_migration_order: 49 36 runs-on: ubuntu-latest ··· 135 122 uses: actions/checkout@v4 136 123 137 124 - name: Lint 138 - run: docker compose run --quiet-pull lint 125 + run: docker compose run --rm --quiet-pull backend npm run lint 139 126 140 127 - name: Build server 141 - run: DOCKER_BUILDKIT=1 docker build . --target build_backend 128 + run: docker compose run --rm --quiet-pull backend npm run build 142 129 143 130 - name: Migrate CI DBs and Test 144 131 run: | 145 - docker compose run --quiet-pull test 132 + docker compose run --rm --quiet-pull test 146 133 echo "ATTENTION: If this step fails, look in the next step for the migration logs." 147 134 148 135 - # Only output the migration logs if the prior step failed, as they ··· 171 158 uses: actions/checkout@v4 172 159 173 160 - name: Lint client 174 - run: docker compose run --quiet-pull lint-client 161 + run: docker compose run --rm --quiet-pull client npm run lint 175 162 176 163 - name: Build client 177 - # Without DOCKER_BUILDKIT we'll attempt to build the backend as well 178 - run: DOCKER_BUILDKIT=1 docker build client 164 + run: docker compose run --rm --quiet-pull client npm run build 179 165 180 166
+1
Dockerfile
··· 9 9 # native modules, and we don't really care about the larger image size. 10 10 FROM node:24.14.1-bullseye-slim AS server_base 11 11 WORKDIR /app 12 + RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* 12 13 13 14 COPY ["server/package.json", "server/package-lock.json", "./"] 14 15 RUN npm ci
+33
README.md
··· 102 102 103 103 See `server/bin/README.md` for detailed usage instructions and examples. 104 104 105 + ## Running CI Locally 106 + 107 + All PR checks are defined as `docker compose` services to reproduce any CI job locally. 108 + 109 + | CI job | Local command | 110 + | --- | --- | 111 + | `check_generated_graphql` | `docker compose run --rm codegen-check` | 112 + | `check_api_server` (lint) | `docker compose run --rm backend npm run lint` | 113 + | `check_api_server` (build) | `docker compose build backend` | 114 + | `check_api_server` (test) | `docker compose run --rm test` | 115 + | `run_frontend_checks_if_changed` (lint) | `docker compose run --rm client npm run lint` | 116 + | `run_frontend_checks_if_changed` (build) | `docker compose build client` | 117 + 118 + Run the full suite (stops at first failure): 119 + 120 + ```bash 121 + docker compose run --rm codegen-check \ 122 + && docker compose run --rm backend npm run lint \ 123 + && docker compose build backend \ 124 + && docker compose run --rm test \ 125 + && docker compose run --rm client npm run lint \ 126 + && docker compose build client 127 + ``` 128 + 129 + Tear down: 130 + 131 + ```bash 132 + docker compose down # stop containers, keep DB volumes 133 + docker compose down -v # also drop DB volumes (fresh DBs next run) 134 + ``` 135 + 136 + `check_migration_order` runs only in GitHub Actions — it's GitHub-specific and not needed locally. When adding a migration, use `date -u +"%Y.%m.%dT%H.%M.%S"` for the filename prefix and CI will pass. 137 + 105 138 # Code Structure 106 139 107 140 Server Code ( `/server` ):
+20 -4
docker-compose.yaml
··· 100 100 redis: 101 101 condition: service_started 102 102 103 + # Regenerate GraphQL types and fail if the working tree drifts. 104 + # Mirrors the `check_generated_graphql` CI job. 105 + # node_modules is in a dedicated volume so the install doesn't clobber the host's node_modules. 106 + codegen-check: 107 + build: 108 + context: . 109 + dockerfile: Dockerfile 110 + target: server_base 111 + working_dir: /src 112 + command: bash -c 'set -e 113 + && git config --global --add safe.directory /src 114 + && npm ci 115 + && npm run generate 116 + && [[ -z "$(git status --porcelain)" ]]' 117 + volumes: 118 + - .:/src 119 + - codegen_node_modules:/src/node_modules 103 120 104 - lint: 121 + backend: 105 122 build: 106 123 context: . 107 124 dockerfile: Dockerfile 108 125 target: server_base 109 - command: npm run lint 110 126 111 - lint-client: 127 + client: 112 128 build: 113 129 context: client 114 130 target: client_base 115 - command: npm run lint 116 131 volumes: 117 132 - ./client/eslint:/app/eslint 118 133 - ./client/.eslintrc.cjs:/app/.eslintrc.cjs ··· 166 181 scylla_data: 167 182 redis_data: 168 183 clickhouse_data: 184 + codegen_node_modules: