From 6f7476d17723966786febfebc966fff6a933b5f6 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 20:15:53 +0100 Subject: [PATCH 01/21] move macos build into reusable workflow --- .github/workflows/build-macos.yml | 117 ++++++++++++++++++++++++ .github/workflows/neon_extra_builds.yml | 104 +-------------------- 2 files changed, 118 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/build-macos.yml diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 000000000000..098364e5af9f --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,117 @@ +name: Check neon with MacOS builds + +on: + workflow_call: + +env: + RUST_BACKTRACE: 1 + COPT: '-Werror' + +# TODO: move `check-*` and `files-changed` jobs to the "Caller" Workflow +# We should care about that as Github has limitations: +# - You can connect up to four levels of workflows +# - You can call a maximum of 20 unique reusable workflows from a single workflow file. +# https://docs.github.com/en/actions/sharing-automations/reusing-workflows#limitations +jobs: + files-changed: + name: Detect what files changed + runs-on: ubuntu-22.04 + timeout-minutes: 3 + outputs: + postgres_changes: ${{ steps.postgres_changes.outputs.changes }} + steps: + - name: Checkout + uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 # v4.1.7 + with: + submodules: true + + - name: Check for Postgres changes + uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3 + id: postgres_changes + with: + token: ${{ github.token }} + filters: | + v14: ['vendor/postgres-v14/**', 'Makefile', 'pgxn/**'] + v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**'] + v16: ['vendor/postgres-v16/**', 'Makefile', 'pgxn/**'] + v17: ['vendor/postgres-v17/**', 'Makefile', 'pgxn/**'] + base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }} + ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || ''}} + + check-macos-build: + needs: [ files-changed ] + if: | + needs.files-changed.outputs.postgres_changes != '[]' && ( + contains(github.event.pull_request.labels.*.name, 'run-extra-build-macos') || + contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || + github.ref_name == 'main' + ) + timeout-minutes: 30 + runs-on: ubuntu-22.04 + strategy: + matrix: + postgres-version: ${{ fromJSON(needs.files-changed.outputs.postgres_changes) }} + env: + # Use release build only, to have less debug info around + # Hence keeping target/ (and general cache size) smaller + BUILD_TYPE: release + steps: + - name: Checkout main repo + uses: actions/checkout@v4 + + - name: Checkout submodule vendor/postgres-${{ matrix.postgres-version }} + run: | + git submodule init vendor/postgres-${{ matrix.postgres-version }} + git submodule update --depth 1 + + - name: Install build dependencies + run: | + echo brew install flex bison openssl protobuf icu4c + + - name: Set pg ${{ matrix.postgres-version }} for caching + id: pg_rev + run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-${{ matrix.postgres-version }}) + + - name: Cache postgres ${{ matrix.postgres-version }} build + id: cache_pg + uses: actions/cache@v4 + with: + path: pg_install/${{ matrix.postgres-version }} + key: v1-${{ runner.os }}-${{ runner.arch }}-${{ env.BUILD_TYPE }}-pg-${{ steps.pg_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} + + - name: Set extra env for macOS + run: | + echo 'LDFLAGS=-L/usr/local/opt/openssl@3/lib' >> $GITHUB_ENV + echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV + + - name: Cache cargo deps + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + !~/.cargo/registry/src + ~/.cargo/git + target + key: v1-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('./Cargo.lock') }}-${{ hashFiles('./rust-toolchain.toml') }}-rust + + - name: Build Postgres ${{ matrix.postgres-version }} + if: steps.cache_pg.outputs.cache-hit != 'true' + run: | + make postgres-${{ matrix.postgres-version }} -j$(sysctl -n hw.cpu) + + - name: Build Neon Pg Ext ${{ matrix.postgres-version }} + run: | + make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.cpu) + + - name: Build walproposer-lib (only for v17) + if: matrix.postgres-version == 'v17' + run: + make walproposer-lib -j$(sysctl -n hw.cpu) + + - name: Run cargo build + if: matrix.postgres-version == 'v17' + run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release + + - name: Check that no warnings are produced + if: matrix.postgres-version == 'v17' + run: ./run_clippy.sh \ No newline at end of file diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 092831adb91d..976c49d7f31c 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -37,109 +37,7 @@ jobs: contains(github.event.pull_request.labels.*.name, 'run-extra-build-macos') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' - timeout-minutes: 90 - runs-on: macos-15 - - env: - # Use release build only, to have less debug info around - # Hence keeping target/ (and general cache size) smaller - BUILD_TYPE: release - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install macOS postgres dependencies - run: brew install flex bison openssl protobuf icu4c - - - name: Set pg 14 revision for caching - id: pg_v14_rev - run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v14) >> $GITHUB_OUTPUT - - - name: Set pg 15 revision for caching - id: pg_v15_rev - run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v15) >> $GITHUB_OUTPUT - - - name: Set pg 16 revision for caching - id: pg_v16_rev - run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v16) >> $GITHUB_OUTPUT - - - name: Set pg 17 revision for caching - id: pg_v17_rev - run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v17) >> $GITHUB_OUTPUT - - - name: Cache postgres v14 build - id: cache_pg_14 - uses: actions/cache@v4 - with: - path: pg_install/v14 - key: v1-${{ runner.os }}-${{ runner.arch }}-${{ env.BUILD_TYPE }}-pg-${{ steps.pg_v14_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - - - name: Cache postgres v15 build - id: cache_pg_15 - uses: actions/cache@v4 - with: - path: pg_install/v15 - key: v1-${{ runner.os }}-${{ runner.arch }}-${{ env.BUILD_TYPE }}-pg-${{ steps.pg_v15_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - - - name: Cache postgres v16 build - id: cache_pg_16 - uses: actions/cache@v4 - with: - path: pg_install/v16 - key: v1-${{ runner.os }}-${{ runner.arch }}-${{ env.BUILD_TYPE }}-pg-${{ steps.pg_v16_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - - - name: Cache postgres v17 build - id: cache_pg_17 - uses: actions/cache@v4 - with: - path: pg_install/v17 - key: v1-${{ runner.os }}-${{ runner.arch }}-${{ env.BUILD_TYPE }}-pg-${{ steps.pg_v17_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - - - name: Set extra env for macOS - run: | - echo 'LDFLAGS=-L/usr/local/opt/openssl@3/lib' >> $GITHUB_ENV - echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV - - - name: Cache cargo deps - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - !~/.cargo/registry/src - ~/.cargo/git - target - key: v1-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('./Cargo.lock') }}-${{ hashFiles('./rust-toolchain.toml') }}-rust - - - name: Build postgres v14 - if: steps.cache_pg_14.outputs.cache-hit != 'true' - run: make postgres-v14 -j$(sysctl -n hw.ncpu) - - - name: Build postgres v15 - if: steps.cache_pg_15.outputs.cache-hit != 'true' - run: make postgres-v15 -j$(sysctl -n hw.ncpu) - - - name: Build postgres v16 - if: steps.cache_pg_16.outputs.cache-hit != 'true' - run: make postgres-v16 -j$(sysctl -n hw.ncpu) - - - name: Build postgres v17 - if: steps.cache_pg_17.outputs.cache-hit != 'true' - run: make postgres-v17 -j$(sysctl -n hw.ncpu) - - - name: Build neon extensions - run: make neon-pg-ext -j$(sysctl -n hw.ncpu) - - - name: Build walproposer-lib - run: make walproposer-lib -j$(sysctl -n hw.ncpu) - - - name: Run cargo build - run: PQ_LIB_DIR=$(pwd)/pg_install/v16/lib cargo build --all --release - - - name: Check that no warnings are produced - run: ./run_clippy.sh + uses: ./.github/workflows/build-macos.yml gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image ] From 5d17810a577973c2ffa9ce0e200a5a8be8db2b70 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 20:24:54 +0100 Subject: [PATCH 02/21] use file-filters --- .github/file-filters.yaml | 42 +++++++++++++++++++++++++++++++ .github/workflows/build-macos.yml | 8 ++---- 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 .github/file-filters.yaml diff --git a/.github/file-filters.yaml b/.github/file-filters.yaml new file mode 100644 index 000000000000..fbb0e943c9af --- /dev/null +++ b/.github/file-filters.yaml @@ -0,0 +1,42 @@ +# From Cargo.toml +Cargo_toml_members: &Cargo_toml_members [ + "compute_tools", + "control_plane", + "control_plane/storcon_cli", + "pageserver", + "pageserver/compaction", + "pageserver/ctl", + "pageserver/client", + "pageserver/pagebench", + "proxy", + "safekeeper", + "storage_broker", + "storage_controller", + "storage_controller/client", + "storage_scrubber", + "workspace_hack", + "libs/compute_api", + "libs/pageserver_api", + "libs/postgres_ffi", + "libs/safekeeper_api", + "libs/desim", + "libs/utils", + "libs/consumption_metrics", + "libs/postgres_backend", + "libs/pq_proto", + "libs/tenant_size_model", + "libs/metrics", + "libs/postgres_connection", + "libs/remote_storage", + "libs/tracing-utils", + "libs/postgres_ffi/wal_craft", + "libs/vm_monitor", + "libs/walproposer", + "libs/wal_decoder", + "libs/postgres_initdb", +] + +v14: ['vendor/postgres-v14/**', 'Makefile', 'pgxn/**'] +v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**'] +v16: ['vendor/postgres-v16/**', 'Makefile', 'pgxn/**'] +v17: ['vendor/postgres-v17/**', 'Makefile', 'pgxn/**', *Cargo_toml_members] diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 098364e5af9f..ed3a5874ff4f 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -30,11 +30,7 @@ jobs: id: postgres_changes with: token: ${{ github.token }} - filters: | - v14: ['vendor/postgres-v14/**', 'Makefile', 'pgxn/**'] - v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**'] - v16: ['vendor/postgres-v16/**', 'Makefile', 'pgxn/**'] - v17: ['vendor/postgres-v17/**', 'Makefile', 'pgxn/**'] + filters: .github/file-filters.yaml base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }} ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || ''}} @@ -47,7 +43,7 @@ jobs: github.ref_name == 'main' ) timeout-minutes: 30 - runs-on: ubuntu-22.04 + runs-on: macos-15 strategy: matrix: postgres-version: ${{ fromJSON(needs.files-changed.outputs.postgres_changes) }} From 9db655b88d5f712b2a0124831f299129c35c5d31 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 21:34:40 +0100 Subject: [PATCH 03/21] move files-changed up one level: form build-macos to neon_extra_builds --- .github/workflows/build-macos.yml | 11 +++++--- .github/workflows/neon_extra_builds.yml | 35 +++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index ed3a5874ff4f..a291664408e0 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -2,6 +2,12 @@ name: Check neon with MacOS builds on: workflow_call: + inputs: + pg_versions: + description: "Array of the pg versions to build for, for example: ['v14', 'v17']" + type: string + default: '[]' + required: true env: RUST_BACKTRACE: 1 @@ -35,9 +41,8 @@ jobs: ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || ''}} check-macos-build: - needs: [ files-changed ] if: | - needs.files-changed.outputs.postgres_changes != '[]' && ( + inputs.pg_versions != '[]' && ( contains(github.event.pull_request.labels.*.name, 'run-extra-build-macos') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' @@ -46,7 +51,7 @@ jobs: runs-on: macos-15 strategy: matrix: - postgres-version: ${{ fromJSON(needs.files-changed.outputs.postgres_changes) }} + postgres-version: ${{ fromJSON(inputs.pg_versions) }} env: # Use release build only, to have less debug info around # Hence keeping target/ (and general cache size) smaller diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 976c49d7f31c..d64554ff7d88 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -31,20 +31,45 @@ jobs: uses: ./.github/workflows/build-build-tools-image.yml secrets: inherit + files-changed: + name: Detect what files changed + runs-on: ubuntu-22.04 + timeout-minutes: 3 + outputs: + postgres_changes: ${{ steps.postgres_changes.outputs.changes }} + steps: + - name: Checkout + uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 # v4.1.7 + with: + submodules: true + + - name: Check for Postgres changes + uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3 + id: postgres_changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yaml + base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }} + ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || '' }} + check-macos-build: - needs: [ check-permissions ] + needs: [ check-permissions, files-changed ] if: | contains(github.event.pull_request.labels.*.name, 'run-extra-build-macos') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' uses: ./.github/workflows/build-macos.yml + with: + pg_versions: ${{ needs.files-changed.outputs.postgres_changes }} gather-rust-build-stats: - needs: [ check-permissions, build-build-tools-image ] + needs: [ check-permissions, build-build-tools-image, files-changed ] if: | - contains(github.event.pull_request.labels.*.name, 'run-extra-build-stats') || - contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || - github.ref_name == 'main' + needs.files-changed.outputs.v17 == 'true' && ( + contains(github.event.pull_request.labels.*.name, 'run-extra-build-stats') || + contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || + github.ref_name == 'main' + ) runs-on: [ self-hosted, large ] container: image: ${{ needs.build-build-tools-image.outputs.image }}-bookworm From 8afa7025d1e0fce1c5690cf74eeb2fd4eca9fd84 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 22:38:35 +0100 Subject: [PATCH 04/21] filter out only v-string for build matrix --- .github/file-filters.yaml | 7 +++++++ .github/workflows/neon_extra_builds.yml | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/file-filters.yaml b/.github/file-filters.yaml index fbb0e943c9af..1a725c0388ee 100644 --- a/.github/file-filters.yaml +++ b/.github/file-filters.yaml @@ -40,3 +40,10 @@ v14: ['vendor/postgres-v14/**', 'Makefile', 'pgxn/**'] v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**'] v16: ['vendor/postgres-v16/**', 'Makefile', 'pgxn/**'] v17: ['vendor/postgres-v17/**', 'Makefile', 'pgxn/**', *Cargo_toml_members] + +rebuild_everything: + - Makefile + +rebuild_extra: + - .github/workflows/neon_build_extra.yml + - .github/worfklows/build-macos.yml diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index d64554ff7d88..dd01245bb43c 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -37,6 +37,7 @@ jobs: timeout-minutes: 3 outputs: postgres_changes: ${{ steps.postgres_changes.outputs.changes }} + rebuild_everything: ${{ steps.files_changed.outputs.rebuild_everything || steps.files_changed.outputs.rebuild_extra }} steps: - name: Checkout uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 # v4.1.7 @@ -45,13 +46,19 @@ jobs: - name: Check for Postgres changes uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3 - id: postgres_changes + id: files_changed with: token: ${{ github.token }} filters: .github/file-filters.yaml base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }} ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || '' }} + - name: Filter out only v-string for build matrix + id: postgres_changes + run: | + v_strings_only_as_json_array=$(echo ${{ steps.files_changed.outputs.chnages }} | jq '.[]|select(test("v\\d+"))' | jq --slurp -c) + echo "changes=${v_strings_only_as_json_array}" | tee -a "${GITHUB_OUTPUT}" + check-macos-build: needs: [ check-permissions, files-changed ] if: | From ef64deaf370482313bf15142aebb4f8a77ce03ea Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 22:46:19 +0100 Subject: [PATCH 05/21] reformat file filter --- .github/file-filters.yaml | 9 ++++----- .github/workflows/neon_extra_builds.yml | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/file-filters.yaml b/.github/file-filters.yaml index 1a725c0388ee..1b2e0b782227 100644 --- a/.github/file-filters.yaml +++ b/.github/file-filters.yaml @@ -41,9 +41,8 @@ v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**'] v16: ['vendor/postgres-v16/**', 'Makefile', 'pgxn/**'] v17: ['vendor/postgres-v17/**', 'Makefile', 'pgxn/**', *Cargo_toml_members] -rebuild_everything: - - Makefile +rebuild_neon_extra: + - .github/workflows/neon_extra_builds.yml -rebuild_extra: - - .github/workflows/neon_build_extra.yml - - .github/worfklows/build-macos.yml +rebuild_macos: + - .github/workflows/build-macos.yml \ No newline at end of file diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index dd01245bb43c..0937b9a822fd 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -37,7 +37,8 @@ jobs: timeout-minutes: 3 outputs: postgres_changes: ${{ steps.postgres_changes.outputs.changes }} - rebuild_everything: ${{ steps.files_changed.outputs.rebuild_everything || steps.files_changed.outputs.rebuild_extra }} + rebuild_everything: ${{ steps.files_changed.outputs.rebuild_neon_extra || steps.files_changed.outputs.rebuild_macos }} + steps: - name: Checkout uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 # v4.1.7 From 30d7579f640938a50b223810c74a3feacb47c713 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 22:54:59 +0100 Subject: [PATCH 06/21] support rebuild-everything in macos-build --- .github/workflows/build-macos.yml | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index a291664408e0..9f55f4aba836 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -8,6 +8,11 @@ on: type: string default: '[]' required: true + rebuild_everything: + description: "If true, rebuild for all versions" + type: boolean + default: false + required: false env: RUST_BACKTRACE: 1 @@ -19,30 +24,9 @@ env: # - You can call a maximum of 20 unique reusable workflows from a single workflow file. # https://docs.github.com/en/actions/sharing-automations/reusing-workflows#limitations jobs: - files-changed: - name: Detect what files changed - runs-on: ubuntu-22.04 - timeout-minutes: 3 - outputs: - postgres_changes: ${{ steps.postgres_changes.outputs.changes }} - steps: - - name: Checkout - uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6 # v4.1.7 - with: - submodules: true - - - name: Check for Postgres changes - uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3 - id: postgres_changes - with: - token: ${{ github.token }} - filters: .github/file-filters.yaml - base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }} - ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || ''}} - check-macos-build: if: | - inputs.pg_versions != '[]' && ( + (inputs.pg_versions != '[]' || inputs.rebuild_everything) && ( contains(github.event.pull_request.labels.*.name, 'run-extra-build-macos') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' @@ -51,7 +35,7 @@ jobs: runs-on: macos-15 strategy: matrix: - postgres-version: ${{ fromJSON(inputs.pg_versions) }} + postgres-version: ${{ inputs.rebuild_everything && fromJson('["v14", "v15", "v16", "v17"]') || fromJSON(inputs.pg_versions) }} env: # Use release build only, to have less debug info around # Hence keeping target/ (and general cache size) smaller From 74f99e5b78e5acd6cc8e16905d91e84ed48eb3bd Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 22:57:16 +0100 Subject: [PATCH 07/21] make pg_Versions optional for macos-build --- .github/workflows/build-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 9f55f4aba836..2793650a6bbd 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -7,7 +7,7 @@ on: description: "Array of the pg versions to build for, for example: ['v14', 'v17']" type: string default: '[]' - required: true + required: false rebuild_everything: description: "If true, rebuild for all versions" type: boolean From 646ce42bd2f912d71f4e3ad5ce3c35804fddd917 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:01:21 +0100 Subject: [PATCH 08/21] output if there are changed for the current pg version --- .github/workflows/neon_extra_builds.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 0937b9a822fd..296eb40576a6 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -36,6 +36,7 @@ jobs: runs-on: ubuntu-22.04 timeout-minutes: 3 outputs: + v17: ${{ steps.files_changed.outputs.v17 }} postgres_changes: ${{ steps.postgres_changes.outputs.changes }} rebuild_everything: ${{ steps.files_changed.outputs.rebuild_neon_extra || steps.files_changed.outputs.rebuild_macos }} From 4965668dcfa4142271f46175a210e4f44c4645db Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:04:48 +0100 Subject: [PATCH 09/21] pass rebuild_everything to macos-build --- .github/workflows/neon_extra_builds.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 296eb40576a6..8858e4a996b7 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -70,6 +70,7 @@ jobs: uses: ./.github/workflows/build-macos.yml with: pg_versions: ${{ needs.files-changed.outputs.postgres_changes }} + rebuild_everything: ${{ needs.files-changed.outputs.rebuild_everything }} gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image, files-changed ] From 2ec664f75724d3efee7f99ac792acaca3f652d9d Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:07:35 +0100 Subject: [PATCH 10/21] fromJson() for bool --- .github/workflows/neon_extra_builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 8858e4a996b7..308001e8a99f 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -70,7 +70,7 @@ jobs: uses: ./.github/workflows/build-macos.yml with: pg_versions: ${{ needs.files-changed.outputs.postgres_changes }} - rebuild_everything: ${{ needs.files-changed.outputs.rebuild_everything }} + rebuild_everything: ${{ fromJson(needs.files-changed.outputs.rebuild_everything) }} gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image, files-changed ] From 22e019656fe14ef8d6a85fa8e14c90fbd11499cb Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:15:39 +0100 Subject: [PATCH 11/21] fix sysctl, also run rust-build-stats for rebuild_everything and cache cargo only for v17 --- .github/workflows/build-macos.yml | 13 +++++++------ .github/workflows/neon_extra_builds.yml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 2793650a6bbd..5553240902cd 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -69,7 +69,8 @@ jobs: echo 'LDFLAGS=-L/usr/local/opt/openssl@3/lib' >> $GITHUB_ENV echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV - - name: Cache cargo deps + - name: Cache cargo deps (only for v17) + if: matrix.postgres-version == 'v17' uses: actions/cache@v4 with: path: | @@ -82,21 +83,21 @@ jobs: - name: Build Postgres ${{ matrix.postgres-version }} if: steps.cache_pg.outputs.cache-hit != 'true' run: | - make postgres-${{ matrix.postgres-version }} -j$(sysctl -n hw.cpu) + make postgres-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) - name: Build Neon Pg Ext ${{ matrix.postgres-version }} run: | - make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.cpu) + make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.ncpu) - name: Build walproposer-lib (only for v17) if: matrix.postgres-version == 'v17' run: - make walproposer-lib -j$(sysctl -n hw.cpu) + make walproposer-lib -j$(sysctl -n hw.ncpu) - - name: Run cargo build + - name: Run cargo build (only for v17) if: matrix.postgres-version == 'v17' run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release - - name: Check that no warnings are produced + - name: Check that no warnings are produced (only for v17) if: matrix.postgres-version == 'v17' run: ./run_clippy.sh \ No newline at end of file diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 308001e8a99f..867333068621 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -75,7 +75,7 @@ jobs: gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image, files-changed ] if: | - needs.files-changed.outputs.v17 == 'true' && ( + (needs.files-changed.outputs.v17 == 'true' || needs.files-changed.outputs.rebuild_everything) && ( contains(github.event.pull_request.labels.*.name, 'run-extra-build-stats') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' From 61de071f89af06edad09ef0ff7f137e9aca3c1a0 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:18:59 +0100 Subject: [PATCH 12/21] fix comparison to true --- .github/workflows/neon_extra_builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 867333068621..377c1bdbffc2 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -75,7 +75,7 @@ jobs: gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image, files-changed ] if: | - (needs.files-changed.outputs.v17 == 'true' || needs.files-changed.outputs.rebuild_everything) && ( + (needs.files-changed.outputs.v17 == 'true' || needs.files-changed.outputs.rebuild_everything == 'true') && ( contains(github.event.pull_request.labels.*.name, 'run-extra-build-stats') || contains(github.event.pull_request.labels.*.name, 'run-extra-build-*') || github.ref_name == 'main' From 2bce7c80b8a5a5f2d2326999281c409e864bedcd Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:24:34 +0100 Subject: [PATCH 13/21] make postgres-headers before Cargo build --- .github/workflows/build-macos.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 5553240902cd..6b89d2502944 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -94,6 +94,11 @@ jobs: run: make walproposer-lib -j$(sysctl -n hw.ncpu) + - name: Get postgres headers + if: matrix.postgres-version == 'v17' + run: | + make postgres-headers -j$(sysctl hw.ncpu) + - name: Run cargo build (only for v17) if: matrix.postgres-version == 'v17' run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release From 9f2bcbce437c4b02a6cd5df3f296bcc7b5ddc5b6 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:30:46 +0100 Subject: [PATCH 14/21] syscl -n hw.ncpu --- .github/workflows/build-macos.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 6b89d2502944..0e7c6ef837db 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -97,11 +97,11 @@ jobs: - name: Get postgres headers if: matrix.postgres-version == 'v17' run: | - make postgres-headers -j$(sysctl hw.ncpu) + make postgres-headers -j$(sysctl -n hw.ncpu) - name: Run cargo build (only for v17) if: matrix.postgres-version == 'v17' - run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release + run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release -j$(sysctl -n hw.ncpu) - name: Check that no warnings are produced (only for v17) if: matrix.postgres-version == 'v17' From 488d4c4bb9cc49a65a880de8fce3adf6b06f3548 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:40:19 +0100 Subject: [PATCH 15/21] debug v17 only --- .github/workflows/build-macos.yml | 2 +- .github/workflows/neon_extra_builds.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0e7c6ef837db..9eddee2c74b5 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -97,7 +97,7 @@ jobs: - name: Get postgres headers if: matrix.postgres-version == 'v17' run: | - make postgres-headers -j$(sysctl -n hw.ncpu) + make postgres-headers-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) - name: Run cargo build (only for v17) if: matrix.postgres-version == 'v17' diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index 377c1bdbffc2..bf642db493fd 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -69,8 +69,8 @@ jobs: github.ref_name == 'main' uses: ./.github/workflows/build-macos.yml with: - pg_versions: ${{ needs.files-changed.outputs.postgres_changes }} - rebuild_everything: ${{ fromJson(needs.files-changed.outputs.rebuild_everything) }} + pg_versions: '["v17"]' # ${{ needs.files-changed.outputs.postgres_changes }} + rebuild_everything: ${{ fromJSON('false') }} # ${{ fromJson(needs.files-changed.outputs.rebuild_everything) }} gather-rust-build-stats: needs: [ check-permissions, build-build-tools-image, files-changed ] From 424baccf43f76dac1c82347cf8d3524fdd4e5cdc Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 25 Nov 2024 23:47:55 +0100 Subject: [PATCH 16/21] git submodule update --depth 2 --recursive --- .github/workflows/build-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 9eddee2c74b5..053785a72657 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -47,7 +47,7 @@ jobs: - name: Checkout submodule vendor/postgres-${{ matrix.postgres-version }} run: | git submodule init vendor/postgres-${{ matrix.postgres-version }} - git submodule update --depth 1 + git submodule update --depth 2 --recursive - name: Install build dependencies run: | From 1445e69c3cdde6d2b08169da376220577721c232 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Tue, 26 Nov 2024 00:17:43 +0100 Subject: [PATCH 17/21] fix --- .github/workflows/build-macos.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 053785a72657..bb6451daf3c7 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -51,11 +51,11 @@ jobs: - name: Install build dependencies run: | - echo brew install flex bison openssl protobuf icu4c + brew install flex bison openssl protobuf icu4c - name: Set pg ${{ matrix.postgres-version }} for caching id: pg_rev - run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-${{ matrix.postgres-version }}) + run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-${{ matrix.postgres-version }}) | tee -a "${GITHUB_OUTPUT}" - name: Cache postgres ${{ matrix.postgres-version }} build id: cache_pg From 578922499531e326e0a029f485c69420df46bc60 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Tue, 26 Nov 2024 00:35:42 +0100 Subject: [PATCH 18/21] fix --- .github/workflows/build-macos.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index bb6451daf3c7..3388cfce7a64 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -89,16 +89,16 @@ jobs: run: | make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.ncpu) - - name: Build walproposer-lib (only for v17) - if: matrix.postgres-version == 'v17' - run: - make walproposer-lib -j$(sysctl -n hw.ncpu) - - name: Get postgres headers if: matrix.postgres-version == 'v17' run: | make postgres-headers-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) + - name: Build walproposer-lib (only for v17) + if: matrix.postgres-version == 'v17' + run: + make walproposer-lib -j$(sysctl -n hw.ncpu) + - name: Run cargo build (only for v17) if: matrix.postgres-version == 'v17' run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release -j$(sysctl -n hw.ncpu) From 20b0046980658f217970ef6bd6a4e8e2b2a7228f Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Tue, 26 Nov 2024 00:50:52 +0100 Subject: [PATCH 19/21] build v16 and v17 --- .github/workflows/build-macos.yml | 20 ++++++++++---------- .github/workflows/neon_extra_builds.yml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 3388cfce7a64..9baf92b8e620 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -70,7 +70,7 @@ jobs: echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV - name: Cache cargo deps (only for v17) - if: matrix.postgres-version == 'v17' + if: matrix.postgres-version == 'v16' uses: actions/cache@v4 with: path: | @@ -89,20 +89,20 @@ jobs: run: | make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.ncpu) - - name: Get postgres headers - if: matrix.postgres-version == 'v17' - run: | - make postgres-headers-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) - - name: Build walproposer-lib (only for v17) if: matrix.postgres-version == 'v17' run: make walproposer-lib -j$(sysctl -n hw.ncpu) - - name: Run cargo build (only for v17) - if: matrix.postgres-version == 'v17' + - name: Get postgres headers + if: matrix.postgres-version == 'v16' + run: | + make postgres-headers-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) + + - name: Run cargo build (only for v16) + if: matrix.postgres-version == 'v16' run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release -j$(sysctl -n hw.ncpu) - - name: Check that no warnings are produced (only for v17) - if: matrix.postgres-version == 'v17' + - name: Check that no warnings are produced (only for v16) + if: matrix.postgres-version == 'v16' run: ./run_clippy.sh \ No newline at end of file diff --git a/.github/workflows/neon_extra_builds.yml b/.github/workflows/neon_extra_builds.yml index bf642db493fd..715c270d64ed 100644 --- a/.github/workflows/neon_extra_builds.yml +++ b/.github/workflows/neon_extra_builds.yml @@ -69,7 +69,7 @@ jobs: github.ref_name == 'main' uses: ./.github/workflows/build-macos.yml with: - pg_versions: '["v17"]' # ${{ needs.files-changed.outputs.postgres_changes }} + pg_versions: '["v16", "v17"]' # ${{ needs.files-changed.outputs.postgres_changes }} rebuild_everything: ${{ fromJSON('false') }} # ${{ fromJson(needs.files-changed.outputs.rebuild_everything) }} gather-rust-build-stats: From e7257a8d5f578d5e2c3ca486b6ba6766f0171c6e Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Tue, 26 Nov 2024 01:05:02 +0100 Subject: [PATCH 20/21] that should work --- .github/workflows/build-macos.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 9baf92b8e620..63b660d0158d 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -49,6 +49,12 @@ jobs: git submodule init vendor/postgres-${{ matrix.postgres-version }} git submodule update --depth 2 --recursive + - name: Checkout extra v16 submodule vendor/postgres-${{ matrix.postgres-version }} + if: matrix.postgres-version == 'v17' + run: | + git submodule init vendor/postgres-v16 + git submodule update --depth 2 --recursive + - name: Install build dependencies run: | brew install flex bison openssl protobuf icu4c @@ -70,7 +76,7 @@ jobs: echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV - name: Cache cargo deps (only for v17) - if: matrix.postgres-version == 'v16' + if: matrix.postgres-version == 'v17' uses: actions/cache@v4 with: path: | @@ -89,20 +95,20 @@ jobs: run: | make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.ncpu) + - name: Get postgres headers v16 + if: matrix.postgres-version == 'v17' + run: | + make postgres-headers-v16 -j$(sysctl -n hw.ncpu) + - name: Build walproposer-lib (only for v17) if: matrix.postgres-version == 'v17' run: make walproposer-lib -j$(sysctl -n hw.ncpu) - - name: Get postgres headers - if: matrix.postgres-version == 'v16' - run: | - make postgres-headers-${{ matrix.postgres-version }} -j$(sysctl -n hw.ncpu) - - - name: Run cargo build (only for v16) - if: matrix.postgres-version == 'v16' + - name: Run cargo build (only for v17) + if: matrix.postgres-version == 'v17' run: PQ_LIB_DIR=$(pwd)/pg_install/${{ matrix.postgres-version }}/lib cargo build --all --release -j$(sysctl -n hw.ncpu) - - name: Check that no warnings are produced (only for v16) - if: matrix.postgres-version == 'v16' + - name: Check that no warnings are produced (only for v17) + if: matrix.postgres-version == 'v17' run: ./run_clippy.sh \ No newline at end of file From 052f01a8f5ce7051e06d9cc31608d1b1c0d3b227 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Tue, 26 Nov 2024 01:12:54 +0100 Subject: [PATCH 21/21] that way --- .github/workflows/build-macos.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 63b660d0158d..ef1c68062ed7 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -49,10 +49,10 @@ jobs: git submodule init vendor/postgres-${{ matrix.postgres-version }} git submodule update --depth 2 --recursive - - name: Checkout extra v16 submodule vendor/postgres-${{ matrix.postgres-version }} + - name: Checkout all submodule vendor/postgres-${{ matrix.postgres-version }} if: matrix.postgres-version == 'v17' run: | - git submodule init vendor/postgres-v16 + git submodule init git submodule update --depth 2 --recursive - name: Install build dependencies @@ -95,10 +95,10 @@ jobs: run: | make "neon-pg-ext-${{ matrix.postgres-version }}" -j$(sysctl -n hw.ncpu) - - name: Get postgres headers v16 + - name: Get postgres headers if: matrix.postgres-version == 'v17' run: | - make postgres-headers-v16 -j$(sysctl -n hw.ncpu) + make postgres-headers -j$(sysctl -n hw.ncpu) - name: Build walproposer-lib (only for v17) if: matrix.postgres-version == 'v17'