diff --git a/.github/workflows/elixir_client_tests.yml b/.github/workflows/elixir_client_tests.yml index ebf5cadbe1..f0cf1eb90d 100644 --- a/.github/workflows/elixir_client_tests.yml +++ b/.github/workflows/elixir_client_tests.yml @@ -40,36 +40,56 @@ jobs: run: | docker exec ${{ job.services.postgres.id }} sh -c 'echo "wal_level=logical" >> /var/lib/postgresql/data/postgresql.conf' docker restart ${{ job.services.postgres.id }} + - uses: erlef/setup-beam@v1 with: version-type: strict version-file: ".tool-versions" - - name: Restore dependencies cache + - name: Cache elixir-client dependencies uses: actions/cache@v4 with: path: packages/elixir-client/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/elixir-client/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- + key: ${{ runner.os }}-elixir-client-deps-${{ hashFiles('packages/elixir-client/mix.lock') }} + restore-keys: | + ${{ runner.os }}-elixir-client-deps-${{ hashFiles('packages/elixir-client/mix.lock') }} + ${{ runner.os }}-elixir-client-deps- - - name: Restore compiled code - uses: actions/cache/restore@v4 + - name: Cache elixir-client compiled code + uses: actions/cache@v4 with: path: | packages/elixir-client/_build/*/lib - !packages/elixir-client/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/elixir-client/mix.lock') }} + !packages/elixir-client/_build/*/lib/electric_client + key: "${{ runner.os }}-elixir-client-build-[${{ github.ref_name }}]-${{ github.sha }}" + restore-keys: | + ${{ runner.os }}-elixir-client-build-[${{ github.ref_name }}]-${{ github.sha }} + ${{ runner.os }}-elixir-client-build-[${{ github.ref_name }}]- + ${{ runner.os }}-elixir-client-build- - - name: Install dependencies - run: mix deps.get && mix deps.compile + - name: Cache sync-service dependencies + uses: actions/cache@v4 + with: + path: packages/sync-service/deps + key: "${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps- - - name: Save compiled code - uses: actions/cache/save@v4 + - name: Cache sync-service compiled code + uses: actions/cache@v4 with: path: | - packages/elixir-client/_build/*/lib - !packages/elixir-client/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/elixir-client/mix.lock') }} + packages/sync-service/_build/*/lib + !packages/sync-service/_build/*/lib/electric + key: "${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }}" + restore-keys: | + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }} + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]- + ${{ runner.os }}-sync-service-build- + + - name: Install dependencies + run: mix deps.get && mix deps.compile - name: Compiles without warnings run: mix compile --force --all-warnings --warnings-as-errors @@ -109,15 +129,22 @@ jobs: working-directory: packages/elixir-client steps: - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 with: version-type: strict version-file: ".tool-versions" + - name: Cache dependencies id: cache-deps - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: path: packages/elixir-client/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/elixir-client/mix.lock') }} + key: ${{ runner.os }}-elixir-client-deps-${{ hashFiles('packages/elixir-client/mix.lock') }} + restore-keys: | + ${{ runner.os }}-elixir-client-deps-${{ hashFiles('packages/elixir-client/mix.lock') }} + ${{ runner.os }}-elixir-client-deps- + - run: mix deps.get + - run: mix format --check-formatted diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 2d2675bcc2..fc2cf34645 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -15,18 +15,21 @@ permissions: contents: read jobs: - build: - name: Build and test with PostgreSQL 14 + build_and_test: + name: "Build and test, Postgres ${{ matrix.postgres_version }}" runs-on: ubuntu-latest defaults: run: working-directory: packages/sync-service + strategy: + matrix: + postgres_version: [14, 15] env: MIX_ENV: test - POSTGRES_VERSION: 140006 + POSTGRES_VERSION: "${{ matrix.postgres_version }}0000" services: postgres: - image: postgres:14-alpine + image: "postgres:${{ matrix.postgres_version }}-alpine" env: POSTGRES_PASSWORD: password options: >- @@ -38,97 +41,47 @@ jobs: - 54321:5432 steps: - uses: actions/checkout@v4 + - name: "Set PG settings" run: | docker exec ${{ job.services.postgres.id }} sh -c 'echo "wal_level=logical" >> /var/lib/postgresql/data/postgresql.conf' docker restart ${{ job.services.postgres.id }} + - uses: erlef/setup-beam@v1 with: version-type: strict version-file: ".tool-versions" - - name: Restore dependencies cache - uses: actions/cache@v3 + + - name: Cache dependencies + uses: actions/cache@v4 with: path: packages/sync-service/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/sync-service/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- - - name: Restore compiled code - uses: actions/cache/restore@v4 + key: "${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps- + + - name: Cache compiled code + uses: actions/cache@v4 with: path: | packages/sync-service/_build/*/lib !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} + key: "${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }}" + restore-keys: | + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }} + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]- + ${{ runner.os }}-sync-service-build- + - name: Install dependencies run: mix deps.get && mix deps.compile - - name: Save compiled code - uses: actions/cache/save@v4 - with: - path: | - packages/sync-service/_build/*/lib - !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} + - name: Compiles without warnings run: mix compile --force --all-warnings --warnings-as-errors + - name: Run tests run: mix test - test_pg_15: - name: Build and test with PostgreSQL 15 - runs-on: ubuntu-latest - defaults: - run: - working-directory: packages/sync-service - env: - MIX_ENV: test - POSTGRES_VERSION: 150001 - services: - postgres: - image: postgres:15-alpine - env: - POSTGRES_PASSWORD: password - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 54321:5432 - steps: - - uses: actions/checkout@v4 - - name: "Set PG settings" - run: | - docker exec ${{ job.services.postgres.id }} sh -c 'echo "wal_level=logical" >> /var/lib/postgresql/data/postgresql.conf' - docker restart ${{ job.services.postgres.id }} - - uses: erlef/setup-beam@v1 - with: - version-type: strict - version-file: ".tool-versions" - - name: Restore dependencies cache - uses: actions/cache@v3 - with: - path: packages/sync-service/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/sync-service/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- - - name: Restore compiled code - uses: actions/cache/restore@v4 - with: - path: | - packages/sync-service/_build/*/lib - !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} - - name: Install dependencies - run: mix deps.get && mix deps.compile - - name: Save compiled code - uses: actions/cache/save@v4 - with: - path: | - packages/sync-service/_build/*/lib - !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} - - name: Compiles without warnings - run: mix compile --force --all-warnings --warnings-as-errors - - name: Run tests - run: mix test test/electric/postgres/configuration_test.exs + formatting: name: Check formatting runs-on: ubuntu-latest @@ -137,15 +90,21 @@ jobs: working-directory: packages/sync-service steps: - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 with: version-type: strict version-file: ".tool-versions" - - name: Cache dependencies - id: cache-deps - uses: actions/cache@v4 + + - name: Restore dependencies cache + uses: actions/cache/restore@v4 with: path: packages/sync-service/deps - key: ${{ runner.os }}-mixdeps-${{ hashFiles('packages/sync-service/mix.lock') }} + key: "${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps- + - run: mix deps.get + - run: mix format --check-formatted diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 0767d04c61..5ce5307f98 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -23,37 +23,43 @@ jobs: working-directory: integration-tests steps: - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 with: version-type: strict version-file: ".tool-versions" - - name: Restore dependencies cache - uses: actions/cache@v3 + + - name: Cache dependencies + uses: actions/cache@v4 with: path: packages/sync-service/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/sync-service/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- - - name: Restore compiled code - uses: actions/cache/restore@v4 + key: "${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps- + + - name: Cache compiled code + uses: actions/cache@v4 with: path: | packages/sync-service/_build/*/lib !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} + key: "${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }}" + restore-keys: | + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }} + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]- + ${{ runner.os }}-sync-service-build- + - name: Install dependencies run: mix deps.get && mix deps.compile working-directory: packages/sync-service - - name: Save compiled code - uses: actions/cache/save@v4 - with: - path: | - packages/sync-service/_build/*/lib - !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-test-${{ hashFiles('packages/sync-service/mix.lock') }} + - name: Compile run: mix compile --force --all-warnings --warnings-as-errors working-directory: packages/sync-service + - name: Setup lux run: make + - name: Run integration tests run: ./run.sh diff --git a/.github/workflows/ts_test.yml b/.github/workflows/ts_test.yml index 16d8bb8702..448abf304f 100644 --- a/.github/workflows/ts_test.yml +++ b/.github/workflows/ts_test.yml @@ -86,19 +86,28 @@ jobs: node-version: 20 cache: pnpm - run: pnpm install --frozen-lockfile - - name: Restore dependencies cache + + - name: Cache dependencies uses: actions/cache@v4 with: path: packages/sync-service/deps - key: ${{ runner.os }}-mix-${{ hashFiles('packages/sync-service/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- - - name: Restore compiled code + key: "${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps- + + - name: Cache compiled code uses: actions/cache@v4 with: path: | packages/sync-service/_build/*/lib !packages/sync-service/_build/*/lib/electric - key: ${{ runner.os }}-build-dev-${{ hashFiles('packages/sync-service/mix.lock') }} + key: "${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }}" + restore-keys: | + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]-${{ github.sha }} + ${{ runner.os }}-sync-service-build-[${{ github.ref_name }}]- + ${{ runner.os }}-sync-service-build- + - name: Install dependencies run: mix deps.get && mix deps.compile working-directory: packages/sync-service