Repository navigation
feat: Add client-side cache buster for expired shapes to prevent 409s #4191
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Electric CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths-ignore: | |
| - "website/**" | |
| - "**/README.md" | |
| pull_request: | |
| paths-ignore: | |
| - "website/**" | |
| - "**/README.md" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build_and_test: | |
| name: "Build and test sync-service, Postgres ${{ matrix.postgres_version }}" | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: packages/sync-service | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| postgres_version: [14, 15, 17] | |
| env: | |
| MIX_ENV: test | |
| POSTGRES_VERSION: "${{ matrix.postgres_version }}0000" | |
| services: | |
| postgres: | |
| image: "postgres:${{ matrix.postgres_version }}-alpine" | |
| env: | |
| POSTGRES_PASSWORD: password | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 54321:5432 | |
| pgbouncer: | |
| image: bitnami/pgbouncer:latest | |
| env: | |
| PGBOUNCER_AUTH_TYPE: trust | |
| PGBOUNCER_DATABASE: "*" | |
| PGBOUNCER_POOL_MODE: transaction | |
| POSTGRESQL_HOST: postgres | |
| POSTGRESQL_DATABASE: electric | |
| POSTGRESQL_USERNAME: postgres | |
| POSTGRESQL_PASSWORD: password | |
| ports: | |
| - 65432:6432 | |
| 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 exec ${{ job.services.postgres.id }} sh -c 'echo "max_replication_slots=100" >> /var/lib/postgresql/data/postgresql.conf' | |
| docker restart ${{ job.services.postgres.id }} | |
| - name: Seed the database | |
| run: psql -d postgresql://postgres:password@localhost:54321/postgres?sslmode=disable -f dev/init.sql | |
| - uses: erlef/setup-beam@v1 | |
| with: | |
| version-type: strict | |
| version-file: ".tool-versions" | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: packages/sync-service/deps | |
| key: "${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}" | |
| restore-keys: | | |
| ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }} | |
| ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}- | |
| ${{ 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 }}-sync-service-build-${{ env.MIX_ENV }}-[${{ github.ref_name }}]-${{ github.sha }}" | |
| restore-keys: | | |
| ${{ runner.os }}-sync-service-build-${{ env.MIX_ENV }}-[${{ github.ref_name }}]-${{ github.sha }} | |
| ${{ runner.os }}-sync-service-build-${{ env.MIX_ENV }}-[${{ github.ref_name }}]- | |
| ${{ runner.os }}-sync-service-build-${{ env.MIX_ENV }}- | |
| ${{ 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 | |
| - name: Run tests | |
| run: mix coveralls.json --include slow --cover --export-coverage test | |
| - name: Run telemetry tests | |
| run: | | |
| rm -rf _build/application_test | |
| cp -R _build/test _build/application_test | |
| rm -rf _build/application_test/lib/electric | |
| MIX_TARGET=application mix coveralls.json --only telemetry_target --import-cover cover | |
| - name: Upload coverage reports to CodeCov | |
| uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: elixir,unit-tests,sync-service,postgres-${{ env.POSTGRES_VERSION }} | |
| files: ./cover/excoveralls.json | |
| - name: Upload test results to CodeCov | |
| uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 | |
| if: ${{ !cancelled() }} | |
| env: | |
| DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| flags: elixir,unit-tests,sync-service,postgres-${{ env.POSTGRES_VERSION }} | |
| files: ./junit/regular-test-junit-report.xml,./junit/telemetry-test-junit-report.xml | |
| # Upload all PR test results to single branch - requires overriding branch and commit | |
| override_branch: ${{ github.event_name == 'pull_request' && 'codecov/pr-test-aggregation' || '' }} | |
| override_commit: ${{ github.event_name == 'pull_request' && env.DUMMY_COMMIT_SHA || '' }} | |
| formatting: | |
| name: Check formatting for sync-service | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: packages/sync-service | |
| env: | |
| MIX_ENV: test | |
| 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/restore@v4 | |
| with: | |
| path: packages/sync-service/deps | |
| key: "${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}" | |
| restore-keys: | | |
| ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }} | |
| ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}- | |
| ${{ runner.os }}-sync-service-deps- | |
| - run: mix deps.get | |
| - run: mix format --check-formatted |