Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use reusable workflow for MacOs build #9392

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9814b7c
Add workflow for MacOS build
fedordikarev Oct 14, 2024
f977a62
disable build_and_test for now, run build-macos from neon_extra_build
fedordikarev Oct 14, 2024
10be4cb
fix mistype and remove unnecessary checks
fedordikarev Oct 14, 2024
bd517b1
fix build-macos.yml
fedordikarev Oct 14, 2024
fbc6b7f
Merge branch 'main' into feat/ci_workflow_build_macos_2
fedordikarev Oct 14, 2024
e47c846
trigger changes in pgxs
fedordikarev Oct 14, 2024
f5e21b9
trigger changes
fedordikarev Oct 14, 2024
44c1f52
remove concurrency from build-macos
fedordikarev Oct 14, 2024
350ae9a
try to sparse-checkout
fedordikarev Oct 14, 2024
9da0b4d
actually run makes
fedordikarev Nov 15, 2024
e86abd8
trigger changes to test build
fedordikarev Nov 15, 2024
b2cf879
Merge branch 'main' into feat/ci_workflow_build_macos_2
fedordikarev Nov 15, 2024
3ab7297
fix workflow syntax
fedordikarev Nov 15, 2024
fb05a2e
fix workflow syntax
fedordikarev Nov 15, 2024
22963c7
checkout repo for build
fedordikarev Nov 15, 2024
57f5880
just checkout with submodules
fedordikarev Nov 15, 2024
7ee766c
runs-on: macos-15
fedordikarev Nov 19, 2024
73f494a
will it compile on macos-14?
fedordikarev Nov 19, 2024
3bb61ce
don't build and run on ubuntu for tests
fedordikarev Nov 20, 2024
c4ddac3
Merge branch 'main' into feat/ci_workflow_build_macos_2
fedordikarev Nov 20, 2024
8c9bf3e
checkout only required submodule
fedordikarev Nov 20, 2024
eb8a87d
use sparse checkout
fedordikarev Nov 20, 2024
1bf8857
run git submodule command
fedordikarev Nov 20, 2024
441e769
submodule update --depth 1
fedordikarev Nov 20, 2024
3a3fcb3
now all together and check for build on macos-15
fedordikarev Nov 20, 2024
8d81c83
revert changes from pgxn/neon/Makefile
fedordikarev Nov 20, 2024
aa19a41
dont depend on itself and check that doesn;t rebuild when no changes
fedordikarev Nov 20, 2024
d133f83
check that changes not empty for build matrix
fedordikarev Nov 20, 2024
723a791
check for empty array '[]' not empty string []
fedordikarev Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're ok to use the latest tag (like @v4) for "official" actions from actions org

with:
submodules: true

- name: Check for Postgres changes
uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3
id: postgres_changes
with:
token: ${{ github.token }}
filters: |
postgres-v14: ['vendor/postgres-v14/**', 'Makefile', '.github/workflows/build-macos.yml', 'pgxn/**']
postgres-v15: ['vendor/postgres-v15/**', 'Makefile', '.github/workflows/build-macos.yml', 'pgxn/**']
postgres-v16: ['vendor/postgres-v16/**', 'Makefile', '.github/workflows/build-macos.yml', 'pgxn/**']
postgres-v17: ['vendor/postgres-v17/**', 'Makefile', '.github/workflows/build-macos.yml', '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) || ''}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about having this part in the main build_and_test workflow and trigger build-macos only if there're related changes.

We might want to consider using https://github.com/tj-actions/changed-files (instead of dorny/paths-filter), I found its API nicer


check-macos-build:
needs: [ 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'
timeout-minutes: 30
runs-on: macos-14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've find out, that macos-15 is available, let's switch it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems something has changed in Github runners, as build started to fail on both macos-14 and macos-15 due to ICU library not found.
and there are other complain on that library missing from the image: actions/runner-images#10989

I will anyway get back to macos-15, just to keep track of why build fails now :)

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 with ${{ matrix.postgres-version }} Submodule
uses: actions/checkout@v4
with:
submodules: true
sparse-checkout: |
vendor/${{ matrix.postgres-version }}

- name: Build ${{ matrix.postgres-version }}
run: |
echo make ${{ matrix.postgres-version }}
echo make $(echo "${{ matrix.postgres-version }}" | sed -e 's/postgres-/neon-pg-ext-/')
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
- release
- release-proxy
pull_request:
# pull_request:

defaults:
run:
Expand Down
172 changes: 2 additions & 170 deletions .github/workflows/neon_extra_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,178 +37,10 @@ jobs:
image-tag: ${{ needs.check-build-tools-image.outputs.image-tag }}
secrets: inherit

check-macos-build:
run-macos-build:
needs: [ check-permissions ]
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'
timeout-minutes: 90
runs-on: macos-14

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 pkg-config

- 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

gather-rust-build-stats:
needs: [ check-permissions, build-build-tools-image ]
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'
runs-on: [ self-hosted, large ]
container:
image: ${{ needs.build-build-tools-image.outputs.image }}-bookworm
credentials:
username: ${{ secrets.NEON_DOCKERHUB_USERNAME }}
password: ${{ secrets.NEON_DOCKERHUB_PASSWORD }}
options: --init

env:
BUILD_TYPE: release
# build with incremental compilation produce partial results
# so do not attempt to cache this build, also disable the incremental compilation
CARGO_INCREMENTAL: 0

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

# Some of our rust modules use FFI and need those to be checked
- name: Get postgres headers
run: make postgres-headers -j$(nproc)

- name: Build walproposer-lib
run: make walproposer-lib -j$(nproc)

- name: Produce the build stats
run: PQ_LIB_DIR=$(pwd)/pg_install/v17/lib cargo build --all --release --timings -j$(nproc)

- name: Upload the build stats
id: upload-stats
env:
BUCKET: neon-github-public-dev
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY_DEV }}
run: |
REPORT_URL=https://${BUCKET}.s3.amazonaws.com/build-stats/${SHA}/${GITHUB_RUN_ID}/cargo-timing.html
aws s3 cp --only-show-errors ./target/cargo-timings/cargo-timing.html "s3://${BUCKET}/build-stats/${SHA}/${GITHUB_RUN_ID}/"
echo "report-url=${REPORT_URL}" >> $GITHUB_OUTPUT

- name: Publish build stats report
uses: actions/github-script@v7
env:
REPORT_URL: ${{ steps.upload-stats.outputs.report-url }}
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
with:
script: |
const { REPORT_URL, SHA } = process.env

await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: `${SHA}`,
state: 'success',
target_url: `${REPORT_URL}`,
context: `Build stats (release)`,
})
uses: ./.github/workflows/build-macos.yml
1 change: 1 addition & 0 deletions pgxn/neon/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pgxs/neon/Makefile
# Test to trigger changes 2


MODULE_big = neon
Expand Down