diff --git a/.github/workflows/autoformat.yml b/.github/workflows/elixir_check_formatting.yml similarity index 51% rename from .github/workflows/autoformat.yml rename to .github/workflows/elixir_check_formatting.yml index 82ad018b3e..4a7a963410 100644 --- a/.github/workflows/autoformat.yml +++ b/.github/workflows/elixir_check_formatting.yml @@ -1,55 +1,21 @@ -name: Autoformat & Linting - -# Note: For pull requests, GitHub Actions automatically creates a merge commit -# between your branch and the target branch (usually main), then runs checks on -# that merged state. This ensures the code will be properly formatted after merge. -# If this check fails, you may need to merge main into your branch first. +name: Elixir formatting on: - push: - branches: ['main'] - paths-ignore: - - '**/README.md' - - 'integration-tests/**' pull_request: - paths-ignore: - - '**/README.md' - - 'integration-tests/**' + paths: + - 'packages/electric-telemetry/**' + - 'packages/elixir-client/**' + - 'packages/sync-service/**' permissions: contents: read jobs: - typescript_formatting: - name: TypeScript formatting and linting - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.tool-versions' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Check Prettier formatting - run: pnpm run format:check - - - name: Check ESLint (all packages) - run: pnpm run stylecheck-all - - elixir_formatting: + elixir_check_formatting: strategy: matrix: package: [sync-service, elixir-client, electric-telemetry] - name: Elixir formatting and linting + name: Check Elixir formatting and compilation issues runs-on: ubuntu-latest defaults: run: @@ -72,11 +38,11 @@ jobs: uses: actions/cache/restore@v4 with: path: packages/${{ matrix.package }}/deps - key: "${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/${{ matrix.package }}/mix.lock') }}" + key: "${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }}-${{ hashFiles(format('packages/{0}/mix.lock', matrix.package)) }}" restore-keys: | - ${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/${{ matrix.package }}/mix.lock') }} - ${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }}- - ${{ runner.os }}-${{ matrix.package }}-deps- + ${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }}-${{ hashFiles(format('packages/{0}/mix.lock', matrix.package)) }} + ${{ runner.os }}-${{ matrix.package }}-deps-${{ env.MIX_ENV }} + ${{ runner.os }}-${{ matrix.package }}-deps - name: Restore compiled code uses: actions/cache/restore@v4 @@ -86,11 +52,11 @@ jobs: !packages/${{ matrix.package }}/_build/*/lib/electric !packages/${{ matrix.package }}/_build/*/lib/electric_client !packages/${{ matrix.package }}/_build/*/lib/electric_telemetry - key: "${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }}-${{ hashFiles('packages/${{ matrix.package }}/mix.lock') }}" + key: "${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }}-${{ hashFiles(format('packages/{0}/mix.lock', matrix.package)) }}" restore-keys: | - ${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }}-${{ hashFiles('packages/${{ matrix.package }}/mix.lock') }} - ${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }}- - ${{ runner.os }}-${{ matrix.package }}-build- + ${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }}-${{ hashFiles(format('packages/{0}/mix.lock', matrix.package)) }} + ${{ runner.os }}-${{ matrix.package }}-build-${{ env.MIX_ENV }} + ${{ runner.os }}-${{ matrix.package }}-build - name: Install dependencies run: mix deps.get @@ -98,5 +64,5 @@ jobs: - name: Check Elixir formatting run: mix format --check-formatted - - name: Check Elixir compiles without warnings + - name: Check the package compiles without warnings run: mix compile --force --all-warnings --warnings-as-errors diff --git a/.github/workflows/ts_check_formatting.yml b/.github/workflows/ts_check_formatting.yml new file mode 100644 index 0000000000..866266c63b --- /dev/null +++ b/.github/workflows/ts_check_formatting.yml @@ -0,0 +1,39 @@ +name: TS formatting + +on: + pull_request: + paths-ignore: + - '**/README.md' + - 'integration-tests/**' + - 'packages/electric-telemetry/**' + - 'packages/elixir-client/**' + - 'packages/sync-service/**' + +permissions: + contents: read + +jobs: + ts_check_formatting: + name: Check formatting of TS packages, examples and website + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.tool-versions' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check Prettier formatting + run: pnpm run format:check + + - name: Check ESLint (all packages) + run: pnpm run stylecheck-all diff --git a/packages/elixir-client/mix.exs b/packages/elixir-client/mix.exs index 61a4765866..5d8992e8d2 100644 --- a/packages/elixir-client/mix.exs +++ b/packages/elixir-client/mix.exs @@ -17,17 +17,6 @@ defmodule Electric.Client.MixProject do package: package(), source_url: "#{@github_repo}/tree/main/packages/elixir-client", homepage_url: "https://electric-sql.com", - # This will go away after we upgrade Elixir to 1.19, which expects the public `cli/0` - # function to be defined instead. - preferred_cli_env: [ - dialyzer: :test, - coveralls: :test, - "coveralls.detail": :test, - "coveralls.post": :test, - "coveralls.html": :test, - "coveralls.cobertura": :test, - "coveralls.lcov": :test - ], test_coverage: [ tool: ExCoveralls, ignore_modules: [ diff --git a/packages/sync-service/mix.exs b/packages/sync-service/mix.exs index 889c837ed0..dc5ae5737b 100644 --- a/packages/sync-service/mix.exs +++ b/packages/sync-service/mix.exs @@ -33,17 +33,6 @@ defmodule Electric.MixProject do start_permanent: Mix.env() == :prod, deps: deps(), aliases: aliases(), - # This will go away after we upgrade Elixir to 1.19, which expects the public `cli/0` - # function to be defined instead. - preferred_cli_env: [ - dialyzer: :test, - coveralls: :test, - "coveralls.detail": :test, - "coveralls.post": :test, - "coveralls.html": :test, - "coveralls.cobertura": :test, - "coveralls.lcov": :test - ], releases: [ electric: [ applications: @telemetry_applications_in_release,