Skip to content

Polish paragraph suggestions (#1669) #4316

Polish paragraph suggestions (#1669)

Polish paragraph suggestions (#1669) #4316

Workflow file for this run

name: Tests
permissions: read-all
on:
push:
branches:
- master
- canary
paths-ignore:
- "docs/**"
pull_request:
branches:
- master
paths-ignore:
- "docs/**"
env:
CARGO_TERM_COLOR: always
jobs:
headless_lms:
permissions:
contents: read
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:16.4
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7.2
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Free up disk space
run: |
echo "Space before:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /usr/local/lib/android
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Space after:"
df -h
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
services/headless-lms/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Get service container network
id: get_network
run: |
POSTGRES_CONTAINER=$(docker ps -q -f ancestor=postgres:16.4 | head -1)
if [ -z "$POSTGRES_CONTAINER" ]; then
echo "Postgres container not found, trying redis..."
REDIS_CONTAINER=$(docker ps -q -f ancestor=redis:7.2 | head -1)
if [ -z "$REDIS_CONTAINER" ]; then
echo "No service containers found"
exit 1
fi
NETWORK=$(docker inspect "$REDIS_CONTAINER" --format='{{range $net, $conf := .NetworkSettings.Networks}}{{$net}}{{end}}' | head -1)
else
NETWORK=$(docker inspect "$POSTGRES_CONTAINER" --format='{{range $net, $conf := .NetworkSettings.Networks}}{{$net}}{{end}}' | head -1)
fi
echo "network=$NETWORK" >> "$GITHUB_OUTPUT"
echo "Using network: $NETWORK"
- name: Cargo clippy
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
-e CARGO_TERM_COLOR=always \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
cargo clippy --manifest-path services/headless-lms/Cargo.toml -- -D warnings
- name: Build
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace/services/headless-lms \
-e CARGO_TERM_COLOR=always \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
cargo build --verbose
- name: Set up unit test database
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace/services/headless-lms \
-e DATABASE_URL=postgres://postgres:postgres@postgres/headless_lms_test \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
sqlx database setup
- name: Set up integration test database
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace/services/headless-lms \
-e DATABASE_URL=postgres://postgres:postgres@postgres/headless_lms_integration \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
sqlx database setup
- name: Wait for Redis
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace/services/headless-lms \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
bash -c "timeout 20s bash -c 'until redis-cli -h redis ping; do echo \"Waiting for Redis...\"; sleep 1; done'"
- name: Run tests
run: |
docker run --rm \
--network "${{ steps.get_network.outputs.network }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace/services/headless-lms \
-e CARGO_TERM_COLOR=always \
-e DATABASE_URL=postgres://postgres:postgres@postgres/headless_lms_test \
-e DATABASE_URL_TEST=postgres://postgres:postgres@postgres/headless_lms_integration \
-e REDIS_URL=redis://redis:6379/1 \
eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest \
cargo test --verbose
- name: Test Summary
if: always()
run: |
{
echo "## 🧪 Headless LMS Tests"
echo "- **Status**: ${{ job.status }}"
echo "- **Database**: PostgreSQL 16.4"
echo "- **Cache**: Redis 7.2"
} >> "$GITHUB_STEP_SUMMARY"
cms:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node-pnpm
- name: pnpm install --frozen-lockfile for the root of the repo
run: pnpm install --frozen-lockfile
- name: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile
working-directory: ./services/cms
- name: Run tests
run: pnpm run test
working-directory: ./services/cms
- name: Test Summary
if: always()
run: |
{
echo "## 📝 CMS Tests"
echo "- **Status**: ${{ job.status }}"
echo "- **Service**: CMS"
} >> "$GITHUB_STEP_SUMMARY"
shared-module-common:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node-pnpm
- name: Install dependencies at repository root
run: pnpm install --frozen-lockfile
- name: Install dependencies for shared-module/packages/common
run: pnpm install --frozen-lockfile
working-directory: ./shared-module/packages/common
# Have to run pnpm install on main-frontend because we read next config from there
- name: Install dependencies for services/main-frontend
run: pnpm install --frozen-lockfile
working-directory: ./services/main-frontend
- name: Run tests
run: pnpm run test
working-directory: ./shared-module/packages/common
- name: Test Summary
if: always()
run: |
{
echo "## 🔧 Shared Module Common Tests"
echo "- **Status**: ${{ job.status }}"
echo "- **Service**: Shared Module Common"
} >> "$GITHUB_STEP_SUMMARY"
quizzes:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node-pnpm
- name: pnpm install --frozen-lockfile for the root of the repo
run: pnpm install --frozen-lockfile
- name: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile
working-directory: ./services/quizzes
- name: Run tests
run: pnpm run test
working-directory: ./services/quizzes
- name: Test Summary
if: always()
run: |
{
echo "## ❓ Quizzes Tests"
echo "- **Status**: ${{ job.status }}"
echo "- **Service**: Quizzes"
} >> "$GITHUB_STEP_SUMMARY"
main-frontend:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node-pnpm
- name: pnpm install --frozen-lockfile for the root of the repo
run: pnpm install --frozen-lockfile
- name: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile
working-directory: ./services/main-frontend
- name: Run tests
run: pnpm run test
working-directory: ./services/main-frontend
- name: Test Summary
if: always()
run: |
{
echo "## 🎨 Main Frontend Tests"
echo "- **Status**: ${{ job.status }}"
echo "- **Service**: Main Frontend"
} >> "$GITHUB_STEP_SUMMARY"