diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8c1af37..33056c6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -18,19 +18,18 @@ concurrency: group: ci-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - NODE_VERSION: '20' # matches production (CT 122) and the worker (CT 153) +# Node comes from each job's container image, not actions/setup-node: the runner +# shares one tool cache volume between concurrent jobs, and parallel setup-node +# runs overwrote each other's Node install mid-job. node:20 matches production +# (CT 122) and the worker (CT 153). jobs: lint: name: Lint (eslint) runs-on: ubuntu-latest + container: node:20-bookworm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: ${{ env.NODE_VERSION }} - cache: npm - name: Install dependencies (lockfile only) run: npm ci - name: Run ESLint @@ -47,12 +46,9 @@ jobs: test: name: Test (jest) runs-on: ubuntu-latest + container: node:20-bookworm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: ${{ env.NODE_VERSION }} - cache: npm - name: Install dependencies (lockfile only) run: npm ci - name: Run jest with coverage @@ -61,11 +57,9 @@ jobs: audit: name: Security (npm audit) runs-on: ubuntu-latest + container: node:20-bookworm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: ${{ env.NODE_VERSION }} - name: Audit production and dev dependencies run: npm audit --audit-level=high @@ -75,35 +69,27 @@ jobs: # Official image with Chromium and its system libraries; its version must match # @playwright/test in package.json. container: mcr.microsoft.com/playwright:v1.64.1-noble - services: - mariadb: - image: mariadb:11.4 - env: - MARIADB_RANDOM_ROOT_PASSWORD: '1' - MARIADB_DATABASE: pulse - MARIADB_USER: pulse - MARIADB_PASSWORD: ci-only # throwaway container, never reachable outside the job env: - DB_HOST: mariadb + DB_HOST: 127.0.0.1 DB_PORT: '3306' DB_NAME: pulse DB_USER: pulse - DB_PASSWORD: ci-only + DB_PASSWORD: ci-only # throwaway database inside the job container steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: ${{ env.NODE_VERSION }} - cache: npm - name: Install dependencies (lockfile only) run: npm ci - - name: Wait for MariaDB + - name: Start MariaDB + # Inside the job container: the runner puts jobs on Docker's default bridge + # network, where service containers can't be reached by name. run: | - for i in $(seq 1 60); do - node -e 'require("net").connect(3306, "mariadb").on("connect", () => process.exit(0)).on("error", () => process.exit(1))' && exit 0 - sleep 1 - done - echo "::error::MariaDB service never accepted connections"; exit 1 + apt-get update -qq + DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends mariadb-server >/dev/null + mkdir -p /run/mysqld && chown mysql:mysql /run/mysqld + (mariadbd --user=mysql --bind-address=127.0.0.1 --port=3306 >/tmp/mariadb.log 2>&1 &) + for i in $(seq 1 30); do mariadb-admin ping --silent && break; sleep 1; done + mariadb -e "CREATE DATABASE pulse; CREATE USER 'pulse'@'127.0.0.1' IDENTIFIED BY 'ci-only'; GRANT ALL ON pulse.* TO 'pulse'@'127.0.0.1'" + echo "node $(node --version), $(mariadb --version)" - name: Start Pulse with three workers run: scripts/ci/ui-stack.sh start - name: Run Playwright (desktop and mobile)