Skip to content

Bump min-document from 2.19.0 to 2.19.1 #982

Bump min-document from 2.19.0 to 2.19.1

Bump min-document from 2.19.0 to 2.19.1 #982

name: Unit tests (dockerized)
permissions:
contents: read
pull-requests: read
packages: write
on:
push:
branches:
- development
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-ci
jobs:
precheck:
uses: ./.github/workflows/precheck.yml
secrets: inherit
with:
is_pr: ${{ github.event_name == 'pull_request' }}
pr_number: ${{ github.event.pull_request.number }}
is_draft: ${{ github.event.pull_request.draft }}
pr_title: ${{ github.event.pull_request.title }}
pr_body: ${{ github.event.pull_request.body }}
head_sha: ${{ github.event.pull_request.head.sha }}
ref: ${{ github.ref }}
branch: ${{ github.ref_name }}
event_name: ${{ github.event_name }}
is_protected_push: ${{ github.ref_name == 'development' || github.ref_name == 'production' }}
sha: ${{ github.sha }}
build_ci_image:
name: build_ci_image
needs: precheck
if: needs.precheck.outputs.should_run == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || github.actor == 'dependabot[bot]')
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect CI Dockerfile change
id: changes
shell: bash
run: |
set -euo pipefail
SHOULD_BUILD=false
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
SHOULD_BUILD=true
elif [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch origin "${{ github.base_ref }}":"refs/remotes/origin/${{ github.base_ref }}"
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | grep -q "^\\.github/ci/Dockerfile$"; then
SHOULD_BUILD=true
fi
elif [ "${{ github.event_name }}" = "push" ]; then
if git diff --name-only HEAD^ HEAD | grep -q "^\\.github/ci/Dockerfile$"; then
SHOULD_BUILD=true
fi
fi
echo "should_build=${SHOULD_BUILD}" >> "$GITHUB_OUTPUT"
- name: Log in to GHCR
uses: docker/login-action@v3
if: steps.changes.outputs.should_build == 'true'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
if: steps.changes.outputs.should_build == 'true'
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.changes.outputs.should_build == 'true'
- name: Build and push (cached)
uses: docker/build-push-action@v6
if: steps.changes.outputs.should_build == 'true'
with:
context: .
file: .github/ci/Dockerfile
target: ci
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache,mode=max
api_unit_tests_shards:
needs: [precheck, build_ci_image]
if: needs.precheck.outputs.should_run == 'true'
name: api_unit_tests (shard ${{ matrix.shard }}/4)
runs-on: ubuntu-24.04
container:
image: ghcr.io/${{ github.repository }}-ci:latest
options: --ipc=host
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.0-amd64
ports:
- 9200/tcp
options: >-
--memory=2g
--memory-swap=2g
--memory-swappiness=0
-e="discovery.type=single-node"
-e="xpack.security.enabled=false"
-e="ES_JAVA_OPTS=-Xms1g -Xmx1g"
-e="cluster.routing.allocation.disk.threshold_enabled=false"
-e="logger.level=WARN"
-e="ingest.geoip.downloader.enabled=false"
--health-cmd="curl -f http://localhost:9200"
--health-interval=10s
--health-timeout=10s
--health-retries=10
redis:
image: redis:6.0-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
with:
path: ./node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Ensure Yarn
run: npm i -g [email protected] --force && yarn --version
- name: install dependencies
run: yarn install
- name: Start MongoDB replica set
run: /usr/local/bin/setup-mongo-replica.sh
- name: Wait for MongoDB replica set to be ready
run: |
for i in {1..60}; do
if mongosh --host localhost --port 27017 --quiet --eval 'try { rs.status().myState } catch (e) { print(0) }' | tail -n 1 | grep -q "1"; then
echo "Mongo replica set is PRIMARY and ready"; break
fi
echo "Waiting for Mongo replica set... (attempt $i/60)"
sleep 2
done
- name: Start MinIO (from CI image)
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
run: |
mkdir -p /tmp/minio-data
nohup minio server /tmp/minio-data --address :9000 --console-address :9001 > minio.log 2>&1 &
for i in {1..30}; do if curl -sf http://localhost:9000/minio/health/live >/dev/null; then echo "MinIO is up"; break; fi; sleep 2; done
- name: Forward localhost:6379 to redis:6379
run: |
nohup socat TCP-LISTEN:6379,fork,reuseaddr TCP:redis:6379 &
- name: Run tests (shard ${{ matrix.shard }}/4)
env:
ELASTICSEARCH_URL: http://elasticsearch:9200
DBHOST: localhost:27017
REDIS_HOST: redis
REDIS_PORT: 6379
run: node --expose-gc --no-compilation-cache ./node_modules/.bin/jest app/api app/shared --logHeapUsage --forceExit --maxWorkers=3 --shard=${{ matrix.shard }}/4
api_unit_tests_aggregate:
name: api_unit_tests
needs:
- precheck
- build_ci_image
- api_unit_tests_shards
if: ${{ always() }}
runs-on: ubuntu-24.04
steps:
- name: Aggregate shards result
if: ${{ needs.precheck.outputs.should_run == 'true' }}
run: |
if [ "${{ needs.api_unit_tests_shards.result }}" != "success" ]; then
echo "One or more shards failed"
exit 1
fi
echo "All api_unit_tests shards succeeded"
- name: Mark skipped by precheck
if: ${{ needs.precheck.outputs.should_run != 'true' }}
run: echo "api_unit_tests skipped by precheck"
app_unit_tests:
needs: [precheck, build_ci_image]
if: needs.precheck.outputs.should_run == 'true'
runs-on: ubuntu-24.04
container:
image: ghcr.io/${{ github.repository }}-ci:latest
options: --ipc=host
steps:
- uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
with:
path: ./node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Ensure Yarn
run: npm i -g [email protected] --force && yarn --version
- name: install dependencies
run: yarn install
- name: Run tests
run: node --max-http-header-size 20000 ./node_modules/.bin/jest app/react --forceExit --maxWorkers=3